我有一个以这种方式运行的.bat脚本:
我希望避免等待30秒,并在所有构建过程结束后立即运行服务器。我该怎么办?
这是我的批处理脚本的代码:
@echo off
cd webapp
setlocal enabledelayedexpansion
set params=
FOR /D %%G IN ("*") DO (
cd %%G
@echo on
svn update
call npm install
start /B npm run dev
@echo off
set params=!params! http://localhost:9000/%%G
cd ..
)
cd ..
timeout /t 30 /nobreak
@echo on
start /B node core/server.js
start chrome /new-window !params!
编辑:此处非常困难的事情是npm run dev
是一个无休止的过程:它保持活动状态并一直在关注代码更改。这是它的代码:
node_modules/.bin/webpack --config dev.config.js --watch
修改N.2:
要知道构建过程何时结束(@SomethingDark),我可以这样更改代码:
@echo off
cd webapp
setlocal enabledelayedexpansion
#here I don't have the watch option, so it closes on build finished
set params=
FOR /D %%G IN ("*") DO (
cd %%G
@echo on
svn update
call npm install
start /B npm run build-dev
@echo off
set params=!params! http://localhost:9000/%%G
cd ..
)
cd ..
timeout /t 30 /nobreak
@echo on
start /B node core/server.js
start chrome /new-window !params!
#here I have the watch option, so it keeps alive
FOR /D %%G IN ("*") DO (
cd %%G
@echo on
start /B npm run dev
@echo off
cd ..
)