Skip to content

Commit 413e45d

Browse files
committed
Fix: using cross-spawn-async for spaced paths (fixes #26, fixes #27)
1 parent aa2dd2b commit 413e45d

File tree

5 files changed

+10
-44
lines changed

5 files changed

+10
-44
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
},
2323
"dependencies": {
2424
"babel-runtime": "^6.3.13",
25+
"cross-spawn-async": "^2.1.9",
2526
"minimatch": "^3.0.0",
2627
"ps-tree": "^1.0.1",
27-
"shell-quote": "^1.4.3",
28-
"which": "^1.2.0"
28+
"shell-quote": "^1.4.3"
2929
},
3030
"devDependencies": {
3131
"babel-cli": "^6.4.0",

src/lib/run-task.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
import {parse as parseArgs} from "shell-quote";
77
import spawn from "./spawn";
8-
import whichNpm from "./which-npm";
98

109
/**
1110
* Converts a given stream to an option for `child_process.spawn`.
@@ -52,14 +51,14 @@ function detectStreamKind(stream, std) {
5251
*/
5352
export default function runTask(task, stdin, stdout, stderr, prefixOptions) {
5453
let cp = null;
55-
const promise = whichNpm().then(npmPath => new Promise((resolve, reject) => {
54+
const promise = new Promise((resolve, reject) => {
5655
const stdinKind = detectStreamKind(stdin, process.stdin);
5756
const stdoutKind = detectStreamKind(stdout, process.stdout);
5857
const stderrKind = detectStreamKind(stderr, process.stderr);
5958

6059
// Execute.
6160
cp = spawn(
62-
npmPath,
61+
"npm",
6362
["run-script"].concat(prefixOptions, parseArgs(task)),
6463
{stdio: [stdinKind, stdoutKind, stderrKind]}
6564
);
@@ -78,7 +77,7 @@ export default function runTask(task, stdin, stdout, stderr, prefixOptions) {
7877
cp = null;
7978
resolve({task, code});
8079
});
81-
}));
80+
});
8281

8382
promise.abort = function abort() {
8483
if (cp != null) {

src/lib/spawn-posix.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See LICENSE file in root directory for full license.
55
*/
66
/* eslint no-param-reassign: 0 */
7-
import cp from "child_process";
7+
import crossSpawn from "cross-spawn-async";
88
import getDescendentProcessInfo from "ps-tree";
99

1010
/**
@@ -42,7 +42,7 @@ function kill() {
4242
* @private
4343
*/
4444
export default function spawn(command, args, options) {
45-
const child = cp.spawn(command, args, options);
45+
const child = crossSpawn(command, args, options);
4646
child.kill = kill;
4747

4848
return child;

src/lib/spawn-win32.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
* @copyright 2015 Toru Nagashima. All rights reserved.
44
* See LICENSE file in root directory for full license.
55
*/
6-
import cp from "child_process";
6+
import crossSpawn from "cross-spawn-async";
77

88
/**
99
* Kills the new process and its sub processes forcibly.
1010
* @this ChildProcess
1111
*/
1212
function kill() {
13-
cp.spawn("taskkill", ["/F", "/T", "/PID", this.pid]);
13+
crossSpawn("taskkill", ["/F", "/T", "/PID", this.pid]);
1414
}
1515

1616
/**
@@ -27,7 +27,7 @@ function kill() {
2727
* @private
2828
*/
2929
export default function spawn(command, args, options) {
30-
const child = cp.spawn(command, args, options);
30+
const child = crossSpawn(command, args, options);
3131
child.kill = kill;
3232

3333
return child;

src/lib/which-npm.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)