From 2766bbd1ffacd9a587f6c362438f0ff4ceda991f Mon Sep 17 00:00:00 2001
From: Konstantin Tarkus <koistya@gmail.com>
Date: Wed, 9 Aug 2017 04:35:26 +0300
Subject: [PATCH] Fix the order of arguments in spawned child proc (#2913)

* Fix the order of arguments in spawned child proc

* Update react-scripts.js

* Remove a comma

* Update react-scripts.js
---
 packages/react-scripts/bin/react-scripts.js | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/packages/react-scripts/bin/react-scripts.js b/packages/react-scripts/bin/react-scripts.js
index abb2741f8..1261de6be 100755
--- a/packages/react-scripts/bin/react-scripts.js
+++ b/packages/react-scripts/bin/react-scripts.js
@@ -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':
@@ -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) {
-- 
GitLab