]> git.r.bdr.sh - rbdr/corona-regeln/commitdiff
Use old style readdir
authorRuben Beltran del Rio <redacted>
Sat, 3 Apr 2021 22:56:36 +0000 (00:56 +0200)
committerRuben Beltran del Rio <redacted>
Sat, 3 Apr 2021 22:56:36 +0000 (00:56 +0200)
lib/rule_generator.js

index 5db5240e9db5264420d5004d7eb9cffa2a058602..407f7636ef5ed9b8a2ae835de49f3c02714f04f7 100644 (file)
@@ -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);
+      })
+    });
   }
 }