33 lines
691 B
JavaScript
33 lines
691 B
JavaScript
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
class Util {
|
|
|
|
constructor() {
|
|
throw new Error("Class may not be instantiated.");
|
|
}
|
|
|
|
static readdirRecursive(directory) {
|
|
|
|
const result = [];
|
|
|
|
(function read(directory) {
|
|
const files = fs.readdirSync(directory);
|
|
for(const file of files) {
|
|
const filePath = path.join(directory, file);
|
|
|
|
if(fs.statSync(filePath).isDirectory()) {
|
|
read(filePath);
|
|
} else {
|
|
result.push(filePath);
|
|
}
|
|
}
|
|
}(directory));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = Util; |