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

Moving from vinyl-fs watch (gaze) to chokidar, fixes #1247 #1259

Merged
merged 1 commit into from Sep 25, 2015
Merged

Moving from vinyl-fs watch (gaze) to chokidar, fixes #1247 #1259

merged 1 commit into from Sep 25, 2015

Conversation

ddprrt
Copy link
Contributor

@ddprrt ddprrt commented Sep 16, 2015

I gave integrating chokidar a shot. I hope you don't mind @es128. I see it as some exercise for me, so if you have any better solution, I don't mind having this PR going down ;-)

Naturally, I felt really uncomfortable changing tests ;-) But due to chokidar's different API, I had to. The changes were rather small, though. I also updated the recipes and docs.

Looking forward to your feedback

Fixes #1247

var watcher = gulp.watch(relFile, {cwd: cwd})
.on('change', function(filepath) {
should.exist(filepath);
path.resolve(cwd, filepath).should.equal(path.resolve(tempFile));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one was particular tricky, as chokidar spits out relative file paths instead of absolute ones.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should be based on the input. If watching a relative path, events are emitted with matching relative paths. If you do path.resolve(relFile) at the top you should get absolute paths with the events.

@es128
Copy link
Contributor

es128 commented Sep 16, 2015

I hope you don't mind @es128

Not at all. Happy to have some help and to see this moving forward without me being the bottleneck.


#### fn
Type: `Function`

An [async](#async-support) function to run when a file changes.

`gulp.watch` returns an `EventEmitter` object which emits `change` events with
the [gaze] `event`:
`gulp.watch` returns an `FSWatcher` object that already listens to the `change`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested edit:

returns a wrapped [chokidar] FSWatcher object. If provided, the callback will be triggered upon any add, change, or unlink event. Listeners can also be set directly for any of [chokidar]'s events.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 Changed it.

@phated
Copy link
Member

phated commented Sep 20, 2015

@es128 how are you feeling about this PR now? Everything look similar to what your plans were?

@contra any feedback?

@es128
Copy link
Contributor

es128 commented Sep 20, 2015

So long as you all are comfortable with the resulting API changes, then this implementation LGTM.

@es128
Copy link
Contributor

es128 commented Sep 20, 2015

Oh, btw, I should be able to get chokidar 1.1.0 released next week. This will include fsevents 1.0.0, which now uses node-pre-gyp to make typical installs on Mac much faster and more stable.

console.log('File ' + event.path + ' was ' + event.type);
watcher.on('change', function(path, stats) {
console.log('File ' + path + ' was changed');
if (stats) {
Copy link
Member

Choose a reason for hiding this comment

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

can this be updated so stats is always present? don't like having this be optional

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be a perf hit, and most users don't need/use it. Existing interface doesn't provide a stat object at all afaik, perhaps it just shouldn't be passed through here.

Or perhaps only provide it if the user specified alwaysStat

Copy link
Member

Choose a reason for hiding this comment

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

@es128 maybe just remove it from the example then, it's confusing

Copy link
Member

Choose a reason for hiding this comment

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

👍 on removing it from examples

@yocontra
Copy link
Member

left comments

@ddprrt
Copy link
Contributor Author

ddprrt commented Sep 21, 2015

Just want to let you know that I'll look into everything once I'm back from Italy ;-) (Wednesday the earliest)

@es128
Copy link
Contributor

es128 commented Sep 21, 2015

@ddprrt cool. So if I have some time tonight or tomorrow I may also take a shot at addressing the feedback, starting with your commit as a basis. I believe it's only documentation changes left to do.

Enjoy the rest of your trip!

@yocontra
Copy link
Member

I'm going to be taking point on making sure this gets finished and merged FYI. Ping me when the changes have been pushed to the fork since GH doesn't notify on new commits.

yocontra pushed a commit that referenced this pull request Sep 25, 2015
Moving from vinyl-fs watch (gaze) to chokidar, fixes #1247
@yocontra yocontra merged commit aafcbce into gulpjs:4.0 Sep 25, 2015
@es128
Copy link
Contributor

es128 commented Sep 25, 2015

You want a new PR with docs updates?

@yocontra
Copy link
Member

Merged this so we can get the functionality in, any docs stuff is a part of this #1281

@phated
Copy link
Member

phated commented Sep 25, 2015

We still need to explicitly bump chokidar to 1.1 in the deps so everyone gets the pre-gyp

@es128
Copy link
Contributor

es128 commented Sep 25, 2015

Not strictly necessary, but sure.

@yocontra
Copy link
Member

@phated uses a caret range but I updated it anyways

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

6 participants