add readDir method for getting files in a directory
This commit is contained in:
parent
1f46323dc9
commit
48e1fda6cf
|
@ -149,6 +149,20 @@ class FileUtils {
|
||||||
static async writeJsonToFile(path, json) {
|
static async writeJsonToFile(path, json) {
|
||||||
return this.writeFile(path, JSON.stringify(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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue