Skip to content

Commit 9e7833c

Browse files
committed
Use Node's spawn behavior except default to a shell on Windows
1 parent 1332a19 commit 9e7833c

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

packages/react-dev-utils/crossSpawn.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,36 @@
77

88
'use strict';
99

10-
var crossSpawn = require('cross-spawn');
10+
const { spawn } = require('child_process');
11+
12+
function crossSpawn(file, args, options) {
13+
if (typeof file !== 'string' || file.length === 0) {
14+
throw new TypeError('"file" argument must be a non-empty string');
15+
}
16+
17+
if (Array.isArray(args)) {
18+
args = args.slice(0);
19+
} else if (
20+
args !== undefined &&
21+
(args === null || typeof args !== 'object')
22+
) {
23+
throw new TypeError('Incorrect value of args option');
24+
} else {
25+
options = args;
26+
args = [];
27+
}
28+
29+
if (options === undefined) {
30+
options = {};
31+
} else if (options === null || typeof options !== 'object') {
32+
throw new TypeError('"options" argument must be an object');
33+
}
34+
35+
// Default to using a shell on Windows
36+
if (options.shell === undefined && process.platform === 'win32') {
37+
options.shell = true;
38+
}
39+
return spawn(file, args, options);
40+
}
1141

1242
module.exports = crossSpawn;

packages/react-dev-utils/openBrowser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
var chalk = require('chalk');
1111
var execSync = require('child_process').execSync;
12-
var spawn = require('cross-spawn');
12+
var spawn = require('./crossSpawn');
1313
var opn = require('opn');
1414

1515
// https://github.com/sindresorhus/opn#app

packages/react-dev-utils/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
"address": "1.0.3",
4040
"babel-code-frame": "6.26.0",
4141
"chalk": "1.1.3",
42-
"cross-spawn": "5.1.0",
4342
"detect-port-alt": "1.1.3",
4443
"escape-string-regexp": "1.0.5",
4544
"filesize": "3.5.11",

0 commit comments

Comments
 (0)