12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
-
-
- "use strict";
-
-
-
-
-
- const fs = require("fs"),
- path = require("path");
-
- const rulesDirCache = {};
-
-
-
-
-
-
- module.exports = function(relativeRulesDir, cwd) {
-
- const rulesDir = relativeRulesDir
- ? path.resolve(cwd, relativeRulesDir)
- : path.join(__dirname, "rules");
-
-
- if (rulesDirCache[rulesDir]) {
- return rulesDirCache[rulesDir];
- }
-
- const rules = Object.create(null);
-
- fs.readdirSync(rulesDir).forEach(file => {
- if (path.extname(file) !== ".js") {
- return;
- }
- rules[file.slice(0, -3)] = path.join(rulesDir, file);
- });
- rulesDirCache[rulesDir] = rules;
-
- return rules;
- };
|