From d9052f63cb9f7408d879064425e214d22defe47e Mon Sep 17 00:00:00 2001 From: Behnam Mohammadi <itten@live.com> Date: Sat, 5 Oct 2019 23:37:18 +0330 Subject: [PATCH] clean code --- packages/react-scripts/bin/react-scripts.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/react-scripts/bin/react-scripts.js b/packages/react-scripts/bin/react-scripts.js index 7e6e29025..c5be4a5e8 100755 --- a/packages/react-scripts/bin/react-scripts.js +++ b/packages/react-scripts/bin/react-scripts.js @@ -17,19 +17,15 @@ process.on('unhandledRejection', err => { const spawn = require('react-dev-utils/crossSpawn'); const args = process.argv.slice(2); - -const scriptIndex = args.findIndex( - x => x === 'build' || x === 'eject' || x === 'start' || x === 'test' -); +const scripts = ['build', 'eject', 'start', 'test']; +const scriptIndex = args.findIndex(arg => scripts.includes(arg)); const script = scriptIndex === -1 ? args[0] : args[scriptIndex]; const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : []; -if (['build', 'eject', 'start', 'test'].includes(script)) { +if (scripts.includes(script)) { const result = spawn.sync( 'node', - nodeArgs - .concat(require.resolve('../scripts/' + script)) - .concat(args.slice(scriptIndex + 1)), + nodeArgs.concat(require.resolve('../scripts/' + script)).concat(args.slice(scriptIndex + 1)), { stdio: 'inherit' } ); if (result.signal) { @@ -52,7 +48,5 @@ if (['build', 'eject', 'start', 'test'].includes(script)) { } else { console.log('Unknown script "' + script + '".'); console.log('Perhaps you need to update react-scripts?'); - console.log( - 'See: https://facebook.github.io/create-react-app/docs/updating-to-new-releases' - ); + console.log('See: https://facebook.github.io/create-react-app/docs/updating-to-new-releases'); } -- GitLab