Batch file exits after starting One Node Script application

I need to run some UglifyJS2 scripts using Node. I added the command that I want to run to the bat file and it works fine.

When I add a second command, for example "cd ..", the command fails! Very confusing.

cd go somewhere uglifyjs ..\somescript -o ..\somefile.min.js --source-map ..\somemap.js.map --screw-ie8 cd .. 

I would like to be able to run several different scripts from the same bat file.

 uglifyjs ..\somescript1 -o ..\somefile1.min.js uglifyjs ..\somescript2 -o ..\somefile2.min.js uglifyjs ..\somescript3 -o ..\somefile3.min.js 

I'm not sure if this is a problem in Node, Uglify or the expected behavior.

+7
windows batch-file uglifyjs uglifyjs2
source share
1 answer

I am not sure about your installation, but you are probably calling uglifyjs.cmd or uglifyjs.bat , and when you call the batch file from another batch file, the execution is transferred to the called file and this will not return to the caller.

If you want to call the second batch and that if it ends, execution continues in the caller, you need to use the call command

 cd go somewhere call uglifyjs ..\somescript -o ..\somefile.min.js --source-map ..\somemap.js.map --screw-ie8 cd .. 
+10
source share

All Articles