Refactoring per PR comments
This commit is contained in:
parent
8a4a573d59
commit
5da7870265
12 changed files with 316 additions and 312 deletions
16
src/util.ts
16
src/util.ts
|
|
@ -768,3 +768,19 @@ export function doesDirectoryExist(dirPath: string): boolean {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of files in a given directory.
|
||||
*/
|
||||
export function listFolder(dir: string): string[] {
|
||||
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||
let files: string[] = [];
|
||||
for (const entry of entries) {
|
||||
if (entry.isFile()) {
|
||||
files.push(path.resolve(dir, entry.name));
|
||||
} else if (entry.isDirectory()) {
|
||||
files = files.concat(listFolder(path.resolve(dir, entry.name)));
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue