-const { readdir } = require('fs/promises');
+const { readdir } = require('fs');
const { join, resolve } = require('path');
const internals = {
async readRules() {
- const ruleFiles = await readdir(internals.kRulesDirectory);
+ const ruleFiles = await internals.readdir(internals.kRulesDirectory);
const rules = ruleFiles
.filter((file) => file.match(/.js$/))
.map((file) => require(join(internals.kRulesDirectory, file)));
internals.rules = rules.sort(() => Math.random() - 0.5)
+ },
+
+ readdir(path) {
+ return new Promise((resolve, reject) => {
+
+ readdir(path, (err, files) => {
+
+ if (err) {
+ return reject(err);
+ }
+
+ return resolve(files);
+ })
+ });
}
}