Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch File Exits After Running One Node Application Script

I need to run several UglifyJS2 scripts with Node. I've added the command I want to run to a bat file and it runs OK.

When I add a second command, like "cd ..", the command isn't executed! Very confusing.

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

I'd 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 whether this is an issue in Node, Uglify, or expected behavior.

like image 339
Greg Avatar asked Jun 04 '14 18:06

Greg


1 Answers

I am not sure about your install, but probably you are calling a uglifyjs.cmd or uglifyjs.bat, and when you call a batch file from inside another batch file, the execution is transfered to the called file and it does not return to the caller.

If you want to call a second batch and that, when if finishes, 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 ..
like image 129
MC ND Avatar answered Sep 28 '22 18:09

MC ND