Create .bat file to open Nodejs terminal and execute one or more commands

1

I would like to create a .bat file to automate a process I have to do every day.

When I start working, I open the terminal of nodejs, access the directory of my project (in my case I use babel) and then I need to execute the command npm run babel .

The problem is that I work on more than one project. Then I sometimes have to navigate the terminal to the directory and then I need to run the command to start babel.

I would like to create a .bat file for each project, so that everything is already configured and when I click on the .bat file of the project I want, it opens the nodejs terminal and executes the commands I want. Is this possible?

    
asked by anonymous 11.09.2016 / 17:16

1 answer

0

Just create a iniciar_projeto.bat file with something like:

cd C:\Users\Alan\Documentos\Seu_Projeto\
npm run babel

The first command should obviously be changed to the path of your project. This is enough to run the server, if everything is set up correctly.

If .bat is in D: and your project is on the C: drive, you need to change the volume first:

c:
cd C:\Users\Alan\Documentos\Seu_Projeto\
npm run babel
    
11.09.2016 / 23:05