9

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.

Greg
  • 2,810
  • 3
  • 22
  • 33

1 Answers1

15

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 ..
MC ND
  • 65,671
  • 6
  • 67
  • 106