Skip to content

Commit 8b361cd

Browse files
koistyaswengorschewski
authored andcommitted
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
1 parent f2342d3 commit 8b361cd

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/react-scripts/bin/react-scripts-ts-electron.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
'use strict';
1212

1313
const spawn = require('react-dev-utils/crossSpawn');
14-
const script = process.argv[2];
15-
const args = process.argv.slice(3);
14+
const args = process.argv.slice(2);
15+
16+
const scriptIndex = args.findIndex(x =>
17+
x === 'build' || x === 'eject' || x === 'start' || x === 'test');
18+
const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
19+
const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
1620

1721
switch (script) {
1822
case 'build':
@@ -21,7 +25,9 @@ switch (script) {
2125
case 'test': {
2226
const result = spawn.sync(
2327
'node',
24-
[require.resolve(`../scripts/${script}`)].concat(args),
28+
nodeArgs
29+
.concat(require.resolve('../scripts/' + script))
30+
.concat(args.slice(scriptIndex + 1)),
2531
{ stdio: 'inherit' }
2632
);
2733
if (result.signal) {

0 commit comments

Comments
 (0)