Comparing version 0.1.1 to 0.2.0
'use strict'; | ||
const requireStack = require('require-stack'); | ||
const loadModules = require('./loadModules'); | ||
@@ -10,6 +11,7 @@ const listModules = require('./listModules'); | ||
* Creates an Awilix container instance. | ||
* | ||
* @param {Function} options.require The require function to use. Defaults to require-stack. | ||
* @return {AwilixContainer} The container. | ||
*/ | ||
module.exports = function createContainer() { | ||
module.exports = function createContainer(options) { | ||
options = options || {}; | ||
const container = { | ||
@@ -27,3 +29,3 @@ /** | ||
const _loadModulesDeps = { | ||
require: require, | ||
require: options.require || requireStack, | ||
listModules: listModules, | ||
@@ -117,7 +119,5 @@ container: container | ||
container.loadModules = (globPatterns, opts) => { | ||
return loadModules(_loadModulesDeps, globPatterns, opts).then(result => { | ||
return resolveTokens(container).then(() => { | ||
return result; | ||
}); | ||
}); | ||
return loadModules(_loadModulesDeps, globPatterns, opts).then(result => | ||
resolveTokens(container).then(() => result) | ||
); | ||
}; | ||
@@ -124,0 +124,0 @@ |
{ | ||
"name": "awilix", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Simple dependency injection container + helper utilities to facilitate wiring of modules", | ||
@@ -37,4 +37,4 @@ "main": "lib/awilix.js", | ||
"coveralls": "^2.11.6", | ||
"eslint": "^2.2.0", | ||
"eslint-watch": "^2.1.7", | ||
"eslint": "^2.4.0", | ||
"eslint-watch": "^2.1.10", | ||
"istanbul": "^0.4.2", | ||
@@ -46,4 +46,5 @@ "mocha": "^2.4.5", | ||
"dependencies": { | ||
"glob": "^7.0.0" | ||
"glob": "^7.0.0", | ||
"require-stack": "^1.0.1" | ||
} | ||
} |
@@ -6,4 +6,2 @@ 'use strict'; | ||
module.exports = function () { | ||
console.log(__dirname); | ||
const container = awilix.createContainer(); | ||
@@ -10,0 +8,0 @@ return container.loadModules([ |
@@ -6,2 +6,3 @@ 'use strict'; | ||
const fixture = require('./fixture'); | ||
const syntaxErrors = require('./syntax-errors'); | ||
@@ -23,2 +24,9 @@ describe('integration tests', function() { | ||
}); | ||
it('emits nice syntax errors', function() { | ||
const success = sinon.spy(); | ||
return syntaxErrors().then(success, (err) => { | ||
err.toString().should.contain('errorService.js:2'); | ||
}); | ||
}); | ||
}); |
@@ -11,2 +11,10 @@ 'use strict'; | ||
it('uses the passed require function for loadModules', function() { | ||
const requireSpy = sinon.spy(); | ||
const container = createContainer({ require: requireSpy }); | ||
return container.loadModules(['lib/*.js']).then((r) => { | ||
requireSpy.should.have.been.called; | ||
}); | ||
}); | ||
describe('bind', function() { | ||
@@ -13,0 +21,0 @@ it('returns a bound method taking the container as the first parameter', function() { |
Sorry, the diff of this file is not supported yet
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
55822
40
976
0
2
+ Addedrequire-stack@^1.0.1
+ Addedacorn@7.4.1(transitive)
+ Addedacorn-node@1.8.2(transitive)
+ Addedacorn-walk@7.2.0(transitive)
+ Addedrequire-stack@1.0.2(transitive)
+ Addedsyntax-error@1.4.0(transitive)
+ Addedxtend@4.0.2(transitive)