add readDir method for getting files in a directory

This commit is contained in:
Jiiks 2018-01-20 19:41:20 +02:00
parent 1f46323dc9
commit 48e1fda6cf
1 changed files with 14 additions and 0 deletions

View File

@ -149,6 +149,20 @@ class FileUtils {
static async writeJsonToFile(path, json) {
return this.writeFile(path, JSON.stringify(json));
}
static async readDir(path) {
try {
await this.directoryExists(path);
return new Promise((resolve, reject) => {
fs.readdir(path, (err, files) => {
if (err) return reject(err);
resolve(files);
});
});
} catch (err) {
throw err;
}
}
}