Reputation: 1
I am new to Node.js. Recently, I am building a script as below:
"updateData": "node runFirstScript.js && node runSecondScript.js",
"build:desktop": "npm run updateData env1",
"build:mobile": "npm run updateData env2",
I am expecting runFirstScript.js and runSecondScript.js can get the parameters env1
and env2
while they are executed.
Instead of separating as below:
"updateData1": "node runFirstScript.js",
"updateData2": "node runFirstScript.js",
"build:desktop": "npm run updateData1 env1 && npm run updateData2 env1",
"build:mobile": "npm run updateData1 env2 && npm run updateData2 env2",
Is there any optimum solution for this? Thanks
Upvotes: 0
Views: 89
Reputation: 134
Just change && to &,here is the reason what each symbol mean:
& is to make the command run in background. You can execute more than one command in the background, in a single go. For eg: Command1 & Command2 & Command3
&& is to make following commands run only if preceding command succeeds.For eg: Lets say we have Command1 && Command2 && Command3
. Command2 will only execute if Command1 succeed.
Bonus: ; which is useful in your daily productivity, You can run several commands in a single go and the execution of command occurs sequentially. For eg: Command1; Command2; Command3
Upvotes: 1