knifecycle
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -0,1 +1,16 @@ | ||
<a name="2.2.1"></a> | ||
## [2.2.1](https://github.com/nfroidure/knifecycle/compare/v2.2.0...v2.2.1) (2017-10-24) | ||
### Bug Fixes | ||
* **Services mapping:** Fix deep service mapping ([9445cc3](https://github.com/nfroidure/knifecycle/commit/9445cc3)) | ||
### Features | ||
* **Browser:** Add browser support ([d268fbd](https://github.com/nfroidure/knifecycle/commit/d268fbd)) | ||
<a name="2.2.0"></a> | ||
@@ -2,0 +17,0 @@ # [2.2.0](https://github.com/nfroidure/knifecycle/compare/v2.1.1...v2.2.0) (2017-07-30) |
@@ -549,3 +549,3 @@ 'use strict'; | ||
finalHash[mappedName] = servicesHash[serviceName]; | ||
finalHash[serviceName] = servicesHash[mappedName]; | ||
return finalHash; | ||
@@ -627,5 +627,12 @@ }, {}); | ||
serviceDescriptorPromise = serviceDescriptorPromise.then(function (deps) { | ||
debug('Successfully initialized service dependencies:', serviceName); | ||
return deps; | ||
serviceDescriptorPromise = serviceDescriptorPromise.then(function (servicesHash) { | ||
debug('Successfully gathered service dependencies:', serviceName); | ||
return serviceProvider[_util.SPECIAL_PROPS.INJECT].reduce(function (finalHash, dependencyDeclaration) { | ||
var _parseDependencyDecla2 = (0, _util.parseDependencyDeclaration)(dependencyDeclaration), | ||
serviceName = _parseDependencyDecla2.serviceName, | ||
mappedName = _parseDependencyDecla2.mappedName; | ||
finalHash[serviceName] = servicesHash[mappedName]; | ||
return finalHash; | ||
}, {}); | ||
}).then(serviceProvider).then(function (serviceDescriptor) { | ||
@@ -681,5 +688,5 @@ if (!serviceDescriptor) { | ||
return Promise.all(servicesDeclarations.map(function (serviceDeclaration) { | ||
var _parseDependencyDecla2 = (0, _util.parseDependencyDeclaration)(serviceDeclaration), | ||
mappedName = _parseDependencyDecla2.mappedName, | ||
optional = _parseDependencyDecla2.optional; | ||
var _parseDependencyDecla3 = (0, _util.parseDependencyDeclaration)(serviceDeclaration), | ||
mappedName = _parseDependencyDecla3.mappedName, | ||
optional = _parseDependencyDecla3.optional; | ||
@@ -734,4 +741,4 @@ return _this7._getServiceDescriptor(siloContext, injectOnly, mappedName).catch(function (err) { | ||
function _pickServiceNameFromDeclaration(dependencyDeclaration) { | ||
var _parseDependencyDecla3 = (0, _util.parseDependencyDeclaration)(dependencyDeclaration), | ||
serviceName = _parseDependencyDecla3.serviceName; | ||
var _parseDependencyDecla4 = (0, _util.parseDependencyDeclaration)(dependencyDeclaration), | ||
serviceName = _parseDependencyDecla4.serviceName; | ||
@@ -742,5 +749,5 @@ return serviceName; | ||
function _pickMappedNameFromDeclaration(dependencyDeclaration) { | ||
var _parseDependencyDecla4 = (0, _util.parseDependencyDeclaration)(dependencyDeclaration), | ||
serviceName = _parseDependencyDecla4.serviceName, | ||
mappedName = _parseDependencyDecla4.mappedName; | ||
var _parseDependencyDecla5 = (0, _util.parseDependencyDeclaration)(dependencyDeclaration), | ||
serviceName = _parseDependencyDecla5.serviceName, | ||
mappedName = _parseDependencyDecla5.mappedName; | ||
@@ -747,0 +754,0 @@ return mappedName || serviceName; |
@@ -365,3 +365,25 @@ 'use strict'; | ||
it('should instanciate services with mappings', function (done) { | ||
it('should instanciate a single mapped service', function (done) { | ||
var providerStub = _sinon2.default.stub().returns(Promise.resolve({ | ||
service: 'stub' | ||
})); | ||
var providerStub2 = _sinon2.default.stub().returns(Promise.resolve({ | ||
service: 'stub2' | ||
})); | ||
$.provider('mappedStub', (0, _index.inject)(['stub2>mappedStub2'], providerStub)); | ||
$.provider('mappedStub2', providerStub2); | ||
$.run(['stub>mappedStub']).then(function (dependencies) { | ||
_assert2.default.deepEqual(dependencies, { | ||
stub: 'stub' | ||
}); | ||
_assert2.default.deepEqual(providerStub.args, [[{ | ||
stub2: 'stub2' | ||
}]]); | ||
}).then(function () { | ||
return done(); | ||
}).catch(done); | ||
}); | ||
it('should instanciate several services with mappings', function (done) { | ||
var timeServiceStub = _sinon2.default.spy(timeService); | ||
@@ -376,3 +398,3 @@ | ||
$.run(['hash2>aHash2', 'hash3>aHash3', 'time>aTime']).then(function (dependencies) { | ||
_assert2.default.deepEqual(Object.keys(dependencies), ['aHash2', 'aHash3', 'aTime']); | ||
_assert2.default.deepEqual(Object.keys(dependencies), ['hash2', 'hash3', 'time']); | ||
_assert2.default.deepEqual(timeServiceStub.args, [[{}]]); | ||
@@ -379,0 +401,0 @@ }).then(function () { |
{ | ||
"name": "knifecycle", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "Manage your NodeJS processes's lifecycle.", | ||
@@ -39,3 +39,3 @@ "main": "dist/index.js", | ||
"preversion": "npm t && npm run lint && npm run compile", | ||
"test": "mocha --compilers js:babel-register src/*.mocha.js", | ||
"test": "mocha --compilers js:babel-register src/*.mocha.js && karma start karma.conf.js", | ||
"version": "npm run changelog && git add CHANGELOG.md" | ||
@@ -61,2 +61,3 @@ }, | ||
"babel-register": "^6.9.0", | ||
"browserify": "^14.4.0", | ||
"commitizen": "^2.9.6", | ||
@@ -71,2 +72,8 @@ "conventional-changelog-cli": "^1.2.0", | ||
"jsdoc-to-markdown": "^3.0.0", | ||
"karma": "^1.7.0", | ||
"karma-browserify": "^5.1.1", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-firefox-launcher": "^1.0.1", | ||
"karma-mocha": "^1.3.0", | ||
"karma-sauce-launcher": "^1.1.0", | ||
"metapak": "0.0.21", | ||
@@ -76,3 +83,3 @@ "metapak-nfroidure": "0.7.0", | ||
"mocha-lcov-reporter": "1.3.0", | ||
"sinon": "^2.0.0" | ||
"sinon": "^3.0.0" | ||
}, | ||
@@ -79,0 +86,0 @@ "dependencies": { |
@@ -17,2 +17,4 @@ <!-- | ||
[![Browser Support Matrix](https://saucelabs.com/open_sauce/build_matrix/nfroidure.svg)](https://saucelabs.com/u/nfroidure) | ||
Most (maybe all) applications rely on two kinds of dependencies. | ||
@@ -19,0 +21,0 @@ |
@@ -620,3 +620,3 @@ /* eslint max-len: ["warn", { "ignoreComments": true }] */ | ||
finalHash[mappedName] = servicesHash[serviceName]; | ||
finalHash[serviceName] = servicesHash[mappedName]; | ||
return finalHash; | ||
@@ -709,5 +709,13 @@ }, {} | ||
serviceDescriptorPromise = serviceDescriptorPromise | ||
.then((deps) => { | ||
debug('Successfully initialized service dependencies:', serviceName); | ||
return deps; | ||
.then((servicesHash) => { | ||
debug('Successfully gathered service dependencies:', serviceName); | ||
return serviceProvider[SPECIAL_PROPS.INJECT].reduce( | ||
(finalHash, dependencyDeclaration) => { | ||
const { serviceName, mappedName } = | ||
parseDependencyDeclaration(dependencyDeclaration); | ||
finalHash[serviceName] = servicesHash[mappedName]; | ||
return finalHash; | ||
}, {} | ||
); | ||
}) | ||
@@ -714,0 +722,0 @@ .then(serviceProvider) |
@@ -395,3 +395,29 @@ /* eslint max-nested-callbacks:0 */ | ||
it('should instanciate services with mappings', (done) => { | ||
it('should instanciate a single mapped service', (done) => { | ||
const providerStub = sinon.stub() | ||
.returns(Promise.resolve({ | ||
service: 'stub', | ||
})); | ||
const providerStub2 = sinon.stub() | ||
.returns(Promise.resolve({ | ||
service: 'stub2', | ||
})); | ||
$.provider('mappedStub', inject(['stub2>mappedStub2'], providerStub)); | ||
$.provider('mappedStub2', providerStub2); | ||
$.run(['stub>mappedStub']) | ||
.then((dependencies) => { | ||
assert.deepEqual(dependencies, { | ||
stub: 'stub', | ||
}); | ||
assert.deepEqual(providerStub.args, [[{ | ||
stub2: 'stub2', | ||
}]]); | ||
}) | ||
.then(() => done()) | ||
.catch(done); | ||
}); | ||
it('should instanciate several services with mappings', (done) => { | ||
const timeServiceStub = sinon.spy(timeService); | ||
@@ -407,3 +433,3 @@ | ||
.then((dependencies) => { | ||
assert.deepEqual(Object.keys(dependencies), ['aHash2', 'aHash3', 'aTime']); | ||
assert.deepEqual(Object.keys(dependencies), ['hash2', 'hash3', 'time']); | ||
assert.deepEqual(timeServiceStub.args, [[{}]]); | ||
@@ -410,0 +436,0 @@ }) |
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
203536
4214
826
30