knifecycle
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -120,7 +120,8 @@ 'use strict'; | ||
value: function service(serviceName, _service) { | ||
function serviceProvider() { | ||
function serviceProvider(hash) { | ||
return { | ||
servicePromise: 'function' === typeof _service ? _service() : _service | ||
servicePromise: 'function' === typeof _service ? _service(hash) : _service | ||
}; | ||
} | ||
serviceProvider[DEPENDENCIES] = _service[DEPENDENCIES] || []; | ||
this.provider(serviceName, serviceProvider); | ||
@@ -127,0 +128,0 @@ debug('Registered a new service:', serviceName); |
@@ -114,2 +114,19 @@ 'use strict'; | ||
it('should work with service dependencies', function (done) { | ||
$.service('sample', $.depends(['time'], function sampleService(_ref) { | ||
var time = _ref.time; | ||
return Promise.resolve(typeof time === 'undefined' ? 'undefined' : _typeof(time)); | ||
})); | ||
$.constant('time', time); | ||
$.run(['sample']).then(function (dependencies) { | ||
_assert2.default.deepEqual(Object.keys(dependencies), ['sample']); | ||
_assert2.default.deepEqual(dependencies, { | ||
sample: 'function' | ||
}); | ||
done(); | ||
}).catch(done); | ||
}); | ||
it('should work with simple dependencies', function (done) { | ||
@@ -178,4 +195,4 @@ $.constant('ENV', ENV); | ||
function processProvider(_ref) { | ||
var $fatalError = _ref.$fatalError; | ||
function processProvider(_ref2) { | ||
var $fatalError = _ref2.$fatalError; | ||
@@ -189,4 +206,4 @@ return Promise.resolve({ | ||
function dbProvider(_ref2) { | ||
var ENV = _ref2.ENV; | ||
function dbProvider(_ref3) { | ||
var ENV = _ref3.ENV; | ||
@@ -210,5 +227,5 @@ return Promise.resolve().then(function () { | ||
$.run(['time', 'hash', 'db', 'process']).then(function (_ref3) { | ||
var process = _ref3.process; | ||
var db = _ref3.db; | ||
$.run(['time', 'hash', 'db', 'process']).then(function (_ref4) { | ||
var process = _ref4.process; | ||
var db = _ref4.db; | ||
@@ -215,0 +232,0 @@ process.fatalErrorPromise.then(function () { |
{ | ||
"name": "knifecycle", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Manage your NodeJS processes's lifecycle.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -97,9 +97,10 @@ import YError from 'yerror'; | ||
service(serviceName, service) { | ||
function serviceProvider() { | ||
function serviceProvider(hash) { | ||
return { | ||
servicePromise: 'function' === typeof service ? | ||
service() : | ||
service(hash) : | ||
service, | ||
}; | ||
} | ||
serviceProvider[DEPENDENCIES] = service[DEPENDENCIES] || []; | ||
this.provider(serviceName, serviceProvider); | ||
@@ -106,0 +107,0 @@ debug('Registered a new service:', serviceName); |
@@ -113,2 +113,19 @@ import assert from 'assert'; | ||
it('should work with service dependencies', (done) => { | ||
$.service('sample', $.depends(['time'], function sampleService({ time }) { | ||
return Promise.resolve(typeof time); | ||
})); | ||
$.constant('time', time); | ||
$.run(['sample']) | ||
.then((dependencies) => { | ||
assert.deepEqual(Object.keys(dependencies), ['sample']); | ||
assert.deepEqual(dependencies, { | ||
sample: 'function', | ||
}); | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
it('should work with simple dependencies', (done) => { | ||
@@ -115,0 +132,0 @@ $.constant('ENV', ENV); |
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
62499
1166