Skip to content

Commit

Permalink
Fix the order of arguments in spawned child proc (facebook#2913)
Browse files Browse the repository at this point in the history
* Fix the order of arguments in spawned child proc

* Update react-scripts.js

* Remove a comma

* Update react-scripts.js
  • Loading branch information
koistya authored and kasperpeulen committed Sep 24, 2017
1 parent b32e52b commit 99b6b11
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/react-scripts/bin/react-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
'use strict';

const spawn = require('react-dev-utils/crossSpawn');
const script = process.argv[2];
const args = process.argv.slice(3);
const args = process.argv.slice(2);

const scriptIndex = args.findIndex(x =>
x === 'build' || x === 'eject' || x === 'start' || x === 'test');
const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];

switch (script) {
case 'build':
Expand All @@ -21,7 +25,9 @@ switch (script) {
case 'test': {
const result = spawn.sync(
'node',
[require.resolve(`../scripts/${script}`)].concat(args),
nodeArgs
.concat(require.resolve('../scripts/' + script))
.concat(args.slice(scriptIndex + 1)),
{ stdio: 'inherit' }
);
if (result.signal) {
Expand Down

0 comments on commit 99b6b11

Please sign in to comment.