Skip to content

Commit

Permalink
Use Node's spawn behavior except default to a shell on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Nov 19, 2017
1 parent 1332a19 commit 9e7833c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
32 changes: 31 additions & 1 deletion packages/react-dev-utils/crossSpawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,36 @@

'use strict';

var crossSpawn = require('cross-spawn');
const { spawn } = require('child_process');

function crossSpawn(file, args, options) {
if (typeof file !== 'string' || file.length === 0) {
throw new TypeError('"file" argument must be a non-empty string');
}

if (Array.isArray(args)) {
args = args.slice(0);
} else if (
args !== undefined &&
(args === null || typeof args !== 'object')
) {
throw new TypeError('Incorrect value of args option');
} else {
options = args;
args = [];
}

if (options === undefined) {
options = {};
} else if (options === null || typeof options !== 'object') {
throw new TypeError('"options" argument must be an object');
}

// Default to using a shell on Windows
if (options.shell === undefined && process.platform === 'win32') {
options.shell = true;
}
return spawn(file, args, options);
}

module.exports = crossSpawn;
2 changes: 1 addition & 1 deletion packages/react-dev-utils/openBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

var chalk = require('chalk');
var execSync = require('child_process').execSync;
var spawn = require('cross-spawn');
var spawn = require('./crossSpawn');
var opn = require('opn');

// https://github.com/sindresorhus/opn#app
Expand Down
1 change: 0 additions & 1 deletion packages/react-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"address": "1.0.3",
"babel-code-frame": "6.26.0",
"chalk": "1.1.3",
"cross-spawn": "5.1.0",
"detect-port-alt": "1.1.3",
"escape-string-regexp": "1.0.5",
"filesize": "3.5.11",
Expand Down

0 comments on commit 9e7833c

Please sign in to comment.