Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -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');
9 changes: 0 additions & 9 deletions lib/ChildProcessPromise.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
7 changes: 5 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
23 changes: 3 additions & 20 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -535,4 +518,4 @@ describe('child-process-promise', function() {
});
});

});
});