Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

knifecycle

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

knifecycle - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

11

dist/index.js

@@ -246,2 +246,3 @@ 'use strict';

servicesSequence: [],
servicesShutdownsPromises: new Map(),
errorsPromises: []

@@ -278,5 +279,13 @@ };

var serviceDescriptor = siloContext.servicesDescriptors.get(serviceName);
var serviceShutdownPromise = siloContext.servicesShutdownsPromises.get(serviceName);
if (serviceShutdownPromise) {
debug('Reusing a service shutdown promise:', serviceName);
return serviceShutdownPromise;
}
debug('Shutting down a service:', serviceName);
return serviceDescriptor.shutdownProvider ? serviceDescriptor.shutdownProvider() : Promise.resolve();
serviceShutdownPromise = serviceDescriptor.shutdownProvider ? serviceDescriptor.shutdownProvider() : Promise.resolve();
siloContext.servicesShutdownsPromises.set(serviceName, serviceShutdownPromise);
return serviceShutdownPromise;
})).then(_shutdownNextServices.bind(null, reversedServiceSequence));

@@ -283,0 +292,0 @@ }

@@ -369,3 +369,42 @@ 'use strict';

});
it('should work with deeper multi used dependencies', function (done) {
var shutdownCallResolve = void 0;
var shutdownResolve = void 0;
var shutdownCallPromise = new Promise(function (resolve) {
shutdownCallResolve = resolve;
});
var shutdownStub = _sinon2.default.spy(function () {
shutdownCallResolve();
return new Promise(function (resolve) {
shutdownResolve = resolve;
});
});
$.constant('ENV', ENV);
$.provider('hash', $.depends(['ENV'], hashProvider));
$.provider('shutdownChecker', $.depends(['hash'], function () {
return Promise.resolve({
servicePromise: Promise.resolve({
shutdownStub: shutdownStub,
shutdownResolve: shutdownResolve
}),
shutdownProvider: shutdownStub
});
}));
$.provider('hash1', $.depends(['shutdownChecker'], hashProvider));
$.provider('hash2', $.depends(['shutdownChecker'], hashProvider));
$.run(['hash1', 'hash2', '$shutdown', 'shutdownChecker']).then(function (dependencies) {
_assert2.default.deepEqual(Object.keys(dependencies), ['hash1', 'hash2', '$shutdown', 'shutdownChecker']);
shutdownCallPromise.then(function () {
_assert2.default.deepEqual(shutdownStub.args, [[]]);
shutdownResolve();
}).catch(done);
return dependencies.$shutdown();
}).then(done).catch(done);
});
});
});

2

package.json
{
"name": "knifecycle",
"version": "1.0.4",
"version": "1.0.5",
"description": "Manage your NodeJS processes's lifecycle.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -217,2 +217,3 @@ import YError from 'yerror';

servicesSequence: [],
servicesShutdownsPromises: new Map(),
errorsPromises: [],

@@ -250,7 +251,15 @@ };

const serviceDescriptor = siloContext.servicesDescriptors.get(serviceName);
let serviceShutdownPromise = siloContext.servicesShutdownsPromises.get(serviceName);
if(serviceShutdownPromise) {
debug('Reusing a service shutdown promise:', serviceName);
return serviceShutdownPromise;
}
debug('Shutting down a service:', serviceName);
return serviceDescriptor.shutdownProvider ?
serviceShutdownPromise = serviceDescriptor.shutdownProvider ?
serviceDescriptor.shutdownProvider() :
Promise.resolve();
siloContext.servicesShutdownsPromises.set(serviceName, serviceShutdownPromise);
return serviceShutdownPromise;
})

@@ -257,0 +266,0 @@ )

@@ -401,4 +401,47 @@ import assert from 'assert';

it('should work with deeper multi used dependencies', (done) => {
let shutdownCallResolve;
let shutdownResolve;
const shutdownCallPromise = new Promise((resolve) => {
shutdownCallResolve = resolve;
});
const shutdownStub = sinon.spy(() => {
shutdownCallResolve();
return new Promise((resolve) => {
shutdownResolve = resolve;
});
});
$.constant('ENV', ENV);
$.provider('hash', $.depends(['ENV'], hashProvider));
$.provider('shutdownChecker', $.depends(['hash'], () => Promise.resolve({
servicePromise: Promise.resolve({
shutdownStub,
shutdownResolve,
}),
shutdownProvider: shutdownStub,
})));
$.provider('hash1', $.depends(['shutdownChecker'], hashProvider));
$.provider('hash2', $.depends(['shutdownChecker'], hashProvider));
$.run(['hash1', 'hash2', '$shutdown', 'shutdownChecker'])
.then((dependencies) => {
assert.deepEqual(Object.keys(dependencies), [
'hash1', 'hash2', '$shutdown', 'shutdownChecker',
]);
shutdownCallPromise.then(() => {
assert.deepEqual(shutdownStub.args, [[]]);
shutdownResolve();
})
.catch(done);
return dependencies.$shutdown();
})
.then(done)
.catch(done);
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc