Nodemon: How to disable first time "--exec"?

Created on 7 Feb 2015  Â·  8Comments  Â·  Source: remy/nodemon

I am using nodemon like this:
nodemon -w xxxx --exec "my build command"

After launching this command, build command will be triggered. I want to avoid this "first time" trigger, since nothing has changed yet. Any hints?

Most helpful comment

To anyone else that googled and ended up on this issue: --on-change-only

All 8 comments

Use the shell to test if you've run once already or not.
On 7 Feb 2015 19:20, "Tianxiang Chen" [email protected] wrote:

I am using nodemon like this:
nodemon -w xxxx --exec "my build command"

After launching this command, build command will be triggered. I want to
avoid this "first time" trigger, since nothing has changed yet. Any hints?

—
Reply to this email directly or view it on GitHub
https://github.com/remy/nodemon/issues/495.

could you please share an example how we can write this shell?

Afraid not. Stackoverflow is probably the best place for that.

You just want a script that runs in a loop and if the loops has run once
already, then run your script.
On 8 Feb 2015 00:21, "Tianxiang Chen" [email protected] wrote:

could you please share an example how we can write this shell?

—
Reply to this email directly or view it on GitHub
https://github.com/remy/nodemon/issues/495#issuecomment-73390266.

Write a bash which loop in one line is not easy to read, IMHO. I am using the tool in npm script, and creating another .sh looks too heavy.

But never mind, I have found another tool called rewatch which behaves like I described.
Basically I think it is more natural to "detect the change, then trigger something".

Close this one, and hope my information can be useful to others.

I think the -x option shouldn't trigger the first time.
As @txchen said, it watches for change, so when you start the command, nothing has changed yet.
If you look at node-sass watch option for example, it doesn't trigger until there is a change.

-x is used to run the script. So since nodemon runs and restarts, you're saying that it shouldn't run. If this was used to run a node app (for instance), the server would _only_ start when you _restarted_ which doesn't make sense.

I'd be open to a -X option added (expanded to --exec-on-change) via a PR. I'm not 100% sure of what's involved in the change, but it would also have to come with tests.

I'm also wondered that nodemon immediately executes a command although files were not changed

To anyone else that googled and ended up on this issue: --on-change-only

Was this page helpful?
0 / 5 - 0 ratings

Related issues

giacomorebonato picture giacomorebonato  Â·  5Comments

Bastorx picture Bastorx  Â·  5Comments

binarykitchen picture binarykitchen  Â·  5Comments

Mohammad-Quanit picture Mohammad-Quanit  Â·  5Comments

piton13 picture piton13  Â·  3Comments