Batch File Exits After Running One Node Application Script
Asked Answered
O

1

11

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.

Olva answered 4/6, 2014 at 18:32 Comment(0)
R
19

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 ..
Ruperto answered 4/6, 2014 at 18:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.