require-all
Advanced tools
Comparing version 0.0.1 to 0.0.2
18
index.js
var fs = require('fs'); | ||
module.exports = function requireAll(options) { | ||
var files = fs.readdirSync(options.dirname); | ||
var files = fs.readdirSync(options.dirname); | ||
var modules = {}; | ||
files.forEach(function(file) { | ||
var match = file.match(options.filter); | ||
if (!match) return; | ||
var filepath = options.dirname + '/' + file; | ||
if (fs.statSync(filepath).isDirectory()) { | ||
modules[file] = requireAll({ | ||
dirname: filepath, | ||
filter: options.filter | ||
}); | ||
var moduleName = match[1]; | ||
modules[moduleName] = require(options.dirname + '/' + moduleName); | ||
} else { | ||
var match = file.match(options.filter); | ||
if (!match) return; | ||
modules[match[1]] = require(filepath); | ||
} | ||
}); | ||
@@ -14,0 +22,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "An easy way to require all files within a directory.", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "url": "" |
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
36067
16
66