This part of the series is for those people who are tired of executing two command prompts. One for TypeScript compiler and one for web server.
- Day 1 – Part 1
- Day 1 – Part 2
- Day 2
- Day 3
- Day 4 – Part 1
- Day 4 – Execution trick
- Day 4 – Part 2
- Day 4 – Part 3
- Day 5 (Coming soon)
- Day 6 (Coming soon)
- Day 7 (Coming soon)
- Day 8 (Coming soon)
- Day 9 (Coming soon)
- Day 10 (Coming soon)
Step 1– Install Concurrently
“Concurrently” is a node module which will let us execute multiple commands concurrently.
Open command prompt and execute following command.
npm install concurrently –g
Now in command prompt we will be able to demonstrate multiple commands concurrently.
Let’s test the same. Execute following command.
concurrently "dir" "dir"
As you can see, we are trying to execute “dir” command more than once using “concurrently” module.
We will get the following output.
As you can see, it is displaying “dir” command output two times.
Step 2– create a batch file
Now create a file called “AngularStart.bat” in the root folder of our Angular Project and put following contents inside it.
concurrently "tsc -p "TypeScriptFiles" -w"
As you know, “-w” flag will start TypeScript compiler in watch mode. “-p” command let us specify the location of our root TypeScript folder (folders where our tsconfig.json exists).
Note: Here specifying “-p” flag is must, because “tsconfig.json” file is located in some other folder(in TypeScriptFiles folder) and we are executing “tsc” command in some other folder(in root folder of our Angular project).
Step 3 – Execute the batch file
Double click the batch file.
As you can see, executing batch file simply started TypeScript compile in watch mode.
Step 4 – Add web server behavior
So far we have not taken the real advantage of “concurrently” module. Change batch file content to following.
concurrently "tsc -p "TypeScriptFiles" -w" "lite-server"
Step 5 – Execute and Test
Execute the batch file once again. You will notice both TypeScript compiler and lite-server executing concurrently.
It will also launch the browser and executes our application.
Now on, after every lab you can simply execute the batch file and get the output.
Stay tuned for next part.
In case of any queries you can drop a comment. I will try best to reply earliest.
We are Mumbai based software development + Corporate Training firm. We have specialization in .net stack, Mean stack and PHP stack. For any enquiry visit www.justcompile.com or drop an email at SukeshMarla@Gmail.com