mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
refactor: avoid async for iterating over dir entries
Also uses nicer functional pipeline instead of loops.
This commit is contained in:
@@ -55,14 +55,11 @@ export async function getFoldersInFolder(folderPath: string, opts?: {ignoreSymli
|
||||
export async function getFilesInFolder(folderPath: string): Promise<string[]> {
|
||||
if(!(await pathExist(folderPath))){ return []; }
|
||||
|
||||
const files = await readdir(folderPath, {withFileTypes: true});
|
||||
const dirEntries = await readdir(folderPath, {withFileTypes: true})
|
||||
|
||||
const promises = files.map(async file => {
|
||||
if(file.isFile()){ return path.join(folderPath, file.name); }
|
||||
return undefined;
|
||||
});
|
||||
|
||||
return (await Promise.all(promises)).filter(file => file);
|
||||
return dirEntries
|
||||
.filter(entry => entry.isFile())
|
||||
.map(file => path.join(folderPath, file.name));
|
||||
}
|
||||
|
||||
export function moveFolderContent(src: string, dest: string): Observable<Progression>{
|
||||
|
||||
Reference in New Issue
Block a user