0

I have a .bat script that operates this way:

  • Launches build scripts for each webpack project in a directory
  • Waits 30 seconds
  • Runs the server hosting the project
  • Opens Chrome with a tab for every project

I would like to avoid to wait 30 seconds and run the server as soon as all building processes have ended. How can I do this?

This is the code of my batch script:

@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!

EDIT: the very difficult thing here is that npm run dev is a non-ending process: it keeps alive and keeps watching for changes in code. This is its code:

node_modules/.bin/webpack --config dev.config.js --watch

EDIT N.2:

To know when build process ends (@SomethingDark) I can change my code like this:

@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 ..
    )
aschipfl
  • 33,626
  • 12
  • 54
  • 99
Igino Boffa
  • 686
  • 1
  • 9
  • 21

0 Answers0