Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command immediately runs on startup even without a change #114

Open
mikehaertl opened this issue Sep 15, 2016 · 2 comments
Open

Command immediately runs on startup even without a change #114

mikehaertl opened this issue Sep 15, 2016 · 2 comments

Comments

@mikehaertl
Copy link

mikehaertl commented Sep 15, 2016

I have a simple npm-script setup like:

"scripts": {
  "watch:css": "watch 'npm run build:css -s' app/src --ignoreDotFiles",
  "build:css": "node-sass --output-style compressed app/src/main.scss > css/main.css"
}

I find that when I run npm watch:css it always immediately runs the npm run build:css without waiting for a changed file. Is this expected behavior? I would expect that the command does nothing until the first change is detected.

If this is by design, can we get a command flag that waits for the first change?

Additional info: I'm running this inside a docker container and the watched directory is a volume mounted from the host machine.

@airtonix
Copy link

airtonix commented Oct 1, 2016

I expect this as a feature.

That we have different expectations about watch interestingly brings up the throttle and debounce functions in lodash... both of which have flags for leading or trailing.

if you can't be bothered waiting, there is another npm package called watch-cli that performs a trailing action instead of this packages leading behaviour (which I prefer).

Or even better, you can use onchange

@mikehaertl
Copy link
Author

Ok, thanks. Still I it really depends on the use case, so both behaviors can make sense, depending on the project setup. So an additional option flag would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants