From 920552ea237d160fe53e43682567e73af98712d2 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Thu, 22 Nov 2018 23:38:05 +0100 Subject: [PATCH] fix(fs.listFolders): fix --- ts/smartfile.fs.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/ts/smartfile.fs.ts b/ts/smartfile.fs.ts index a3cd924..f9fef4f 100644 --- a/ts/smartfile.fs.ts +++ b/ts/smartfile.fs.ts @@ -257,16 +257,9 @@ export let toVinylSync = function(filePathArg, options = {}) { * lists Folders in a directory on local disk * @returns Promise with an array that contains the folder names */ -export let listFolders = function(pathArg: string, regexFilter?: RegExp): Promise { - let done = plugins.smartpromise.defer(); - let folderArray = plugins.fsExtra.readdirSync(pathArg).filter(function(file) { - return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isDirectory(); - }); - if (regexFilter) { - folderArray = folderArray.filter(fileItem => { - return regexFilter.test(fileItem); - }); - } +export let listFolders = (pathArg: string, regexFilter?: RegExp): Promise => { + const done = plugins.smartpromise.defer(); + const folderArray = listFoldersSync(pathArg, regexFilter); done.resolve(folderArray); return done.promise; }; @@ -275,8 +268,8 @@ export let listFolders = function(pathArg: string, regexFilter?: RegExp): Promis * lists Folders SYNCHRONOUSLY in a directory on local disk * @returns an array with the folder names as strings */ -export let listFoldersSync = function(pathArg: string, regexFilter?: RegExp): string[] { - let folderArray = plugins.fsExtra.readdirSync(pathArg).filter(function(file) { +export let listFoldersSync = (pathArg: string, regexFilter?: RegExp): string[] => { + let folderArray = plugins.fsExtra.readdirSync(pathArg).filter((file) => { return plugins.fsExtra.statSync(plugins.path.join(pathArg, file)).isDirectory(); }); if (regexFilter) {