From: Ruben Beltran del Rio Date: Sat, 3 Apr 2021 22:56:36 +0000 (+0200) Subject: Use old style readdir X-Git-Url: https://git.r.bdr.sh/rbdr/corona-regeln/commitdiff_plain/920e58a2d57f7999d55c43829ffcd28cfe6b6952 Use old style readdir --- 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); + }) + }); } }