Tuesday, May 17, 2016

Using Batch Files to Make Things Easier

Right now I'm working purely on the front end of the project I'm on, so I'm not using an IDE for the most part.  Instead I'm running everything through npm, which makes significant use of the command prompt.  That means that every time I want to start debugging again I have to launch three separate command prompts (one for lite-server, one for gulp, and one for karma), issue a cd command to the correct directory (which is nested pretty deep), then issue my actual command (npm start, gulp watch, and npm test, respectively).  I got tired of doing that over and over so I wrote a batch file to do it for me.
start cmd.exe /k "cd c:\dev\secondLevel\thirdLevel\fourthLevel\fifthLevel && npm start"
start cmd.exe /k "cd c:\dev\secondLevel\thirdLevel\fourthLevel\fifthLevel && gulp watch"
start cmd.exe /k "cd c:\dev\secondLevel\thirdLevel\fourthLevel\fifthLevel && npm test"
As an added bonus, I can use the /min switch to minimize the windows as soon as they're opened.
start cmd.exe /min /k "cd c:\dev\secondLevel\thirdLevel\fourthLevel\fifthLevel && npm start"
start cmd.exe /min /k "cd c:\dev\secondLevel\thirdLevel\fourthLevel\fifthLevel && gulp watch"
start cmd.exe /min /k "cd c:\dev\secondLevel\thirdLevel\fourthLevel\fifthLevel && npm test"

No comments:

Post a Comment