include-all
Advanced tools
Comparing version 0.1.2 to 0.1.3
33
index.js
@@ -58,2 +58,5 @@ var fs = require('fs'); | ||
markDirectories: options.markDirectories, | ||
flattenDirectories: options.flattenDirectories, | ||
keepDirectoryPath: options.keepDirectoryPath, | ||
force: options.force, | ||
@@ -65,6 +68,25 @@ // Keep track of depth | ||
if (options.markDirectories) { | ||
if (options.markDirectories || options.flattenDirectories) { | ||
modules[file].isDirectory = true; | ||
} | ||
if (options.flattenDirectories) { | ||
modules = (function flattenDirectories(modules, accum, path) { | ||
accum = accum || {}; | ||
Object.keys(modules).forEach(function(identity) { | ||
if (typeof(modules[identity]) !== 'object') { | ||
return; | ||
} | ||
if (modules[identity].isDirectory) { | ||
flattenDirectories(modules[identity], accum, path ? path + '/' + identity : identity ); | ||
} else { | ||
accum[options.keepDirectoryPath ? (path ? path + '/' + identity : identity) : identity] = modules[identity]; | ||
} | ||
}); | ||
return accum; | ||
})(modules); | ||
} | ||
} | ||
@@ -99,2 +121,11 @@ // For files, go ahead and add the code to the module map | ||
modules[identity] = options.dontLoad ? true : require(filepath); | ||
if (options.dontLoad) { | ||
modules[identity] = true; | ||
} else { | ||
if (options.force) { | ||
var resolved = require.resolve(filepath); | ||
if (require.cache[resolved]) delete require.cache[resolved]; | ||
} | ||
modules[identity] = require(filepath); | ||
} | ||
} | ||
@@ -101,0 +132,0 @@ }); |
{ | ||
"name": "include-all", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "An easy way to include all node.js modules within a directory. This is a fork of felixge's awesome module, require-all (https://github.com/felixge/node-require-all) which adds the ability to mark an include as **optional**.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
7967
183
4
1