require-directory
Advanced tools
Comparing version 0.0.1 to 0.0.2
10
index.js
var fs = require('fs'); | ||
var join = require('path').join; | ||
var resolve = require('path').resolve; | ||
var requireDirectory = function(m, path){ | ||
var retval = {}; | ||
path = resolve(path); | ||
fs.readdirSync(path).forEach(function(filename){ | ||
if(fs.statSync(path + filename).isDirectory()){ | ||
retval[filename] = requireDirectory(m, path + filename + '/'); | ||
var joined = join(path, filename); | ||
if(fs.statSync(joined).isDirectory()){ | ||
retval[filename] = requireDirectory(m, joined); | ||
}else{ | ||
var name = filename.substring(0, filename.lastIndexOf('.')); | ||
retval[name] = m.require(path + filename); | ||
retval[name] = m.require(joined); | ||
} | ||
@@ -12,0 +16,0 @@ }); |
{ | ||
"author": "Troy Goode <troygoode@gmail.com> (http://github.com/troygoode/)", | ||
"name": "require-directory", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Recursively iterates over specified directory, requiring each file, and returning a nested hash structure containing those libraries.", | ||
@@ -6,0 +6,0 @@ "keywords": ["require", "directory", "library", "recursive"], |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3546
18
5