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

Basic watcher setup #465

Closed
wants to merge 2 commits into from
Closed

Conversation

tomazzaman
Copy link

My first go at continuous watching using chokidar. Feedback welcome.

Fixes #70.

@tomazzaman tomazzaman mentioned this pull request Jan 23, 2016

run();

var watcher = chokidar.watch(cli.input, {persistent: cli.flags.watch});
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking whether it would be more effective watch the whole cwd instead of just test files, but wasn't sure what kind of performance impact would that have.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think all of cwd excluding node_modules.


var cwd = process.cwd();
var watcher = chokidar.watch(cwd, {
persistent: cli.flags.watch,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think no chokidar code should be run unless cli.flags.watch is true. Currently if it's false it means Chokidar probably won't emit changes, but I don't find the documentation entirely clear on this.

@novemberborn
Copy link
Member

Nice!

Some further feature thoughts:

  • It'd be cool to only re-run a test if its test file changed.
  • It'd be really cool to track the dependencies of a test and rerun it when those change (e.g. when you change a file that is being tested, only run the test that loads that file).
  • Could then observe package.json to pick up potential node_modules changes.

@@ -48,6 +49,7 @@ var cli = meow([
' --tap, -t Generate TAP output',
' --verbose, -v Enable verbose output',
' --no-cache Disable the transpiler cache',
' --watch, -w Run tests when files change',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be commented out. We decided to not yet expose this. #70 (comment)

@novemberborn
Copy link
Member

Thinking through this some more, if a test file i deleted that test should no longer run, conversely when a new file is added it should be run.

@sindresorhus
Copy link
Member

Closing in favor of #502.

Sorry @tomazzaman, but that one is a lot more comprehensive.

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

Successfully merging this pull request may close these issues.

None yet

4 participants