1

I'm not looking for a file watcher like nodemon

I have the following scenario:
I'm running a script script.js in nodeJS, In some cases I have to switch to a different git branch (I know how to do this part).
After the git branch is switched, I would like to exit the current run and reload script.js again.

How do I cause nodeJS to reload and run the same script again?
Do I need to start another process and exit the current one?

Nah
  • 1,690
  • 2
  • 26
  • 46
Ron Harlev
  • 16,227
  • 24
  • 89
  • 132
  • 1
    Well, in order to deal with `git` repos in `NodeJS` you can use `nodegit` module. However in order to trigger an event and stop the running `NodeJS` process and restart with new process, you might need to create a Shell script and use it to automate this operation. One example can be seen here: https://medium.com/@aunnnn/automate-digitalocean-deployment-for-node-js-with-git-and-pm2-67a3cfa7a02b – Nah Jun 02 '18 at 00:12

0 Answers0