galactic-bot/util/Util.js

33 lines
691 B
JavaScript
Raw Normal View History

2020-04-08 18:08:46 +02:00
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;