X-Git-Url: https://git.r.bdr.sh/rbdr/corona-regeln/blobdiff_plain/07d8db2bb758686466d4643f575b4b5280cc4791..920e58a2d57f7999d55c43829ffcd28cfe6b6952:/lib/rule_generator.js?ds=sidebyside diff --git a/lib/rule_generator.js b/lib/rule_generator.js index 5db5240..407f763 100644 --- a/lib/rule_generator.js +++ b/lib/rule_generator.js @@ -1,4 +1,4 @@ -const { readdir } = require('fs/promises'); +const { readdir } = require('fs'); const { join, resolve } = require('path'); const internals = { @@ -22,12 +22,26 @@ 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); + }) + }); } }