From bebafe5038cf6437a8106bf4951e978061708960 Mon Sep 17 00:00:00 2001 From: GerA Date: Wed, 2 Oct 2019 08:31:37 +0200 Subject: [PATCH 1/3] handle childProcess exit event --- lib/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 2da7577..0d3a89f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -125,7 +125,7 @@ function doSpawn(method, command, args, options) { cp.on('error', reject); - cp.on('close', function(code) { + var closeHandler = function(code) { if (successfulExitCodes.indexOf(code) === -1) { var commandStr = command + (args.length ? (' ' + args.join(' ')) : ''); var message = '`' + commandStr + '` failed with code ' + code; @@ -144,7 +144,10 @@ function doSpawn(method, command, args, options) { result.code = code; resolve(result); } - }); + }; + + cp.on('close', closeHandler); + cp.on('exit', closeHandler); cpPromise.childProcess = cp; From 3493864827f99d5cda38601592454a483445b738 Mon Sep 17 00:00:00 2001 From: GerA Date: Wed, 2 Oct 2019 10:45:01 +0200 Subject: [PATCH 2/3] fix index.js not being included after install --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 33902d2..5198441 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "child-process-promise", "description": "Simple wrapper around the \"child_process\" module that makes use of promises", - "main": "./index.js", + "main": "index.js", "files": [ "lib", "lib-es5", From 8df56c6547c7f4ca5267ce6130e12b73a5577b2b Mon Sep 17 00:00:00 2001 From: GerA Date: Wed, 20 Nov 2024 13:40:30 +0100 Subject: [PATCH 3/3] update to latest cross-spawn and remove polyfills --- index.js | 6 +----- lib/ChildProcessPromise.js | 9 --------- package.json | 4 +--- test/test.js | 23 +++-------------------- 4 files changed, 5 insertions(+), 37 deletions(-) diff --git a/index.js b/index.js index d1b82e9..288ce9a 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,3 @@ 'use strict'; -if (require('node-version').major >= 4) { - module.exports = require('./lib'); -} else { - module.exports = require('./lib-es5'); -} +module.exports = require('./lib'); diff --git a/lib/ChildProcessPromise.js b/lib/ChildProcessPromise.js index 4ddc0ec..e310338 100644 --- a/lib/ChildProcessPromise.js +++ b/lib/ChildProcessPromise.js @@ -1,14 +1,5 @@ 'use strict'; -var Promise; - -if (require('node-version').major >= 4) { - Promise = global.Promise; -} else { - // Don't use the native Promise in Node.js <4 since it doesn't support subclassing - Promise = require('promise-polyfill'); -} - class ChildProcessPromise extends Promise { constructor(executor) { var resolve; diff --git a/package.json b/package.json index 5198441..ab39442 100644 --- a/package.json +++ b/package.json @@ -31,9 +31,7 @@ "registry": "http://registry.npmjs.org/" }, "dependencies": { - "cross-spawn": "^4.0.2", - "node-version": "^1.0.0", - "promise-polyfill": "^6.0.1" + "cross-spawn": "^7.0.6" }, "devDependencies": { "babel-cli": "^6.11.4", diff --git a/test/test.js b/test/test.js index 87b68a7..f1b2495 100644 --- a/test/test.js +++ b/test/test.js @@ -7,25 +7,8 @@ var path = require('path'); var childProcessPromise = require('../'); -var ChildProcessPromise; -var ChildProcessError; - -if (require('node-version').major >= 4) { - ChildProcessPromise = require('../lib/ChildProcessPromise'); - ChildProcessError = require('../lib/ChildProcessError'); -} else { - ChildProcessPromise = require('../lib-es5/ChildProcessPromise'); - ChildProcessError = require('../lib-es5/ChildProcessError'); -} - -var Promise; - -if (require('node-version').major >= 4) { - Promise = global.Promise; -} else { - // Don't use the native Promise in Node.js <4 since it doesn't support subclassing - Promise = require('promise-polyfill'); -} +var ChildProcessPromise = require('../lib/ChildProcessPromise'); +var ChildProcessError = require('../lib/ChildProcessError'); var NODE_VERSION = process.version; var NODE_PATH = process.argv[0]; @@ -535,4 +518,4 @@ describe('child-process-promise', function() { }); }); -}); \ No newline at end of file +});