Skip to content
Advertisement

Make nodemon ignore changes in all other files except the one it’s running in the same folder

I am running multiple Discord bots from the same folder. Each is controlled by a single .js file. The problem I have is that whenever I make code changes to one of them, all of the bots restart. I can use the --ignore command to make one instance ignore changes to everything in the folder, but it also ignores changes to itself. I’ve tried these two versions in a command line:

nodemon --ignore *.js
nodemon --ignore *.js --watch index.js

In both cases, the index.js bot doesn’t restart when I make changes to it. Is there a way to make it restart on changes to itself while ignoring all other files? I’d prefer not to have to move all these bots into separate folders, which I think is one way to make it work, as that would be more of a hassle and scramble up my existing local source control.

Advertisement

Answer

It is possible to specify multiple --ignore parameters. So you can do like the following

nodemon --ignore bot1.js --ignore bot2.js bot3.js
nodemon --ignore bot1.js --ignore bot3.js bot2.js
nodemon --ignore bot3.js --ignore bot2.js bot1.js
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement