Comparing version 0.3.0-beta-16 to 0.3.0-beta-17
var R = require('ramda') | ||
var normalize = require('path').normalize; | ||
var getConfPaths = require('./dist/get-conf-paths') | ||
function isLocal(path) { | ||
return path[0] === '.'; | ||
} | ||
function getRequrePath(val) { | ||
if (typeof val === 'string') { | ||
return val; | ||
} else { | ||
return val.require; | ||
} | ||
} | ||
function addAmendModule(b, opts, nodeModule) { | ||
@@ -25,27 +14,11 @@ function shouldInclude(key, path) { | ||
var bundleExternal = opts.bundleExternal !== false; | ||
var modules = opts.config.modules; | ||
var parents = opts.config.parents || []; | ||
parents.forEach(function(p) { | ||
addParent(b, opts, p); | ||
}) | ||
Object.keys(modules).forEach(function(key) { | ||
var modulePath = getRequrePath(modules[key]); | ||
if (shouldInclude(key, modulePath)) { | ||
if (nodeModule) { | ||
modulePath = normalize([ nodeModule, modulePath ].join('/')) | ||
} | ||
b.require(modulePath); | ||
var paths = getConfPaths(opts.config) | ||
paths.forEach(function(obj) { | ||
var key = obj.key; | ||
var path = obj.path; | ||
if (shouldInclude(key, path)) { | ||
b.require(p); | ||
} | ||
}); | ||
} | ||
function addParent(b, opts, parentConf) { | ||
var base = process.cwd(); | ||
var configFilePath = normalize([ parentConf.nodeModule, parentConf.configFile ]).join('/'); | ||
var p = require(configFilePath); | ||
var parentOpts = R.assoc('config', p, opts) | ||
b.require(configFilePath) | ||
addAmendModule(b, parentOpts, parentConf.nodeModule) | ||
} | ||
@@ -52,0 +25,0 @@ |
// Generated by CoffeeScript 1.10.0 | ||
var CouldNotLoad, findModule, makePath; | ||
var CouldNotLoad, findModule, makePath, tryFind; | ||
@@ -12,3 +12,6 @@ makePath = require('./make-path'); | ||
try { | ||
return require(fullPath); | ||
return { | ||
instance: require(fullPath), | ||
path: fullPath | ||
}; | ||
} catch (error) { | ||
@@ -24,3 +27,3 @@ e = error; | ||
module.exports = function(base, fileName, callers) { | ||
tryFind = function(base, fileName, callers) { | ||
var e, error; | ||
@@ -34,1 +37,9 @@ try { | ||
}; | ||
exports.instance = function(base, fileName, callers) { | ||
return tryFind(base, fileName, callers).instance; | ||
}; | ||
exports.path = function(base, fileName, callers) { | ||
return tryFind(base, fileName, callers).path; | ||
}; |
@@ -6,3 +6,3 @@ // Generated by CoffeeScript 1.10.0 | ||
findModule = require('./find-module'); | ||
findModule = require('./find-module').instance; | ||
@@ -9,0 +9,0 @@ populateDi = require('./populate-di')(findModule); |
exports.fromConfig = require('./dist/load-config'); | ||
exports.fromNodeConfig = require('./dist/load-node-config'); | ||
exports.Container = require('./dist/container'); |
{ | ||
"name": "amend", | ||
"version": "0.3.0-beta-16", | ||
"version": "0.3.0-beta-17", | ||
"description": "Dependency injection module and IoC container.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
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
35381
34
572
6