Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Revert "Use Node's spawn behavior except default to a shell on Windows"
This reverts commit 9e7833c.
  • Loading branch information
Timer committed Nov 19, 2017
commit 65d335eb9ca95cd567453be6678d14336959632c
48 changes: 1 addition & 47 deletions packages/react-dev-utils/crossSpawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,6 @@

'use strict';

const { spawn, spawnSync } = require('child_process');

// Based on Node's internal normalizeSpawnArguments
// See https://github.com/nodejs/node/blob/97ba69f91543f89d389a4f3fef57c5c6c734df34/lib/child_process.js#L378-L489
function normalizeSpawnArguments(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');
}

// Make a shallow copy so we don't clobber the user's options object.
options = Object.assign({}, options);

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

return { file, args, options };
}

function crossSpawn(file, args, options) {
({ file, args, options } = normalizeSpawnArguments(file, args, options));
return spawn(file, args, options);
}

crossSpawn.sync = function crossSpawnSync(file, args, options) {
({ file, args, options } = normalizeSpawnArguments(file, args, options));
return spawnSync(file, args, options);
};
var crossSpawn = require('cross-spawn');

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('./crossSpawn');
var spawn = require('cross-spawn');
var opn = require('opn');

// https://github.com/sindresorhus/opn#app
Expand Down
1 change: 1 addition & 0 deletions packages/react-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"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
2 changes: 1 addition & 1 deletion packages/react-scripts/scripts/eject.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function adjustPackages(cwd, packages, append, dev) {
let status, output;
if (fs.existsSync(paths.yarnLockFile)) {
({ status, output } = spawnSync(
'yarnpkg',
process.platform === 'win32' ? 'yarn.cmd' : 'yarnpkg',
[append ? 'add' : 'remove', ...packages],
{
stdio: 'pipe',
Expand Down