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

docs: clarify eventType in fs.watch #9318

Closed
wants to merge 4 commits into from
Closed

docs: clarify eventType in fs.watch #9318

wants to merge 4 commits into from

Conversation

seishun
Copy link
Contributor

@seishun seishun commented Oct 27, 2016

Checklist
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

doc

Description of change

'rename' is confusing, and it's not clear what "they" refers to.

Fixes: #9082

'rename' is confusing, and it's not clear what "they" refers to.

Fixes: #9082
@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. labels Oct 27, 2016
Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

A few style nits that don't really matter much, but more importantly: I don't think the information about rename is correct on all operating systems. I could be misreading what's going on, but judging from some of the tests, it appears that whether you get change or rename on file creation (for example) is OS-dependent. See, for example:

var renameEv = common.isSunOS ? 'change' : 'rename';

@@ -1702,8 +1702,11 @@ The listener callback gets two arguments `(eventType, filename)`. `eventType` i
`'rename'` or `'change'`, and `filename` is the name of the file which triggered
the event.

Please note the listener callback is attached to the `'change'` event
fired by [`fs.FSWatcher`][], but they are not the same thing.
Note that `'rename'` is also emitted when a file is deleted or added - in other words,
Copy link
Member

Choose a reason for hiding this comment

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

Nit: no hyphen. ...when a file is deleted or added. In other words, ...

Please note the listener callback is attached to the `'change'` event
fired by [`fs.FSWatcher`][], but they are not the same thing.
Note that `'rename'` is also emitted when a file is deleted or added - in other words,
it's emitted whenever a filename appears or disappears in the directory.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: it's -> it is

it's emitted whenever a filename appears or disappears in the directory.

Also note the listener callback is attached to the `'change'` event fired by
[`fs.FSWatcher`][], but it's not the same thing as the `'change'` value of `eventType`.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: it's -> it is

@seishun
Copy link
Contributor Author

seishun commented Oct 28, 2016

Fixed the nits.

According to my tests, this behavior is consistent across Windows, Linux and MacOS, so I just changed it to "most platforms".

Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

A couple more nits, but LGTM

@@ -1702,8 +1702,11 @@ The listener callback gets two arguments `(eventType, filename)`. `eventType` i
`'rename'` or `'change'`, and `filename` is the name of the file which triggered
the event.

Please note the listener callback is attached to the `'change'` event
fired by [`fs.FSWatcher`][], but they are not the same thing.
Note that on most platforms, `'rename'` is also emitted when a file is deleted or added.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: remove also

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used "also" because it's in addition to being renamed.

Copy link
Member

Choose a reason for hiding this comment

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

I suggested removing it because I think it could be interpreted to mean that both a rename and a change event will be emitted.

I think someone might think it means "A change event is emitted and a rename event is also emitted."

I understand that you mean it as "A rename event is emitted in this case and a rename event is also emitted in this other case."

I'm fine with leaving it the way you have it if you have a strong preference for that. But if it doesn't make much of a difference to you either way, I'd prefer it removed.

Copy link
Contributor Author

@seishun seishun Oct 29, 2016

Choose a reason for hiding this comment

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

I feel like with your suggestion the two sentences somewhat contradict each other...

How about a compromise? Just combine them into one sentence: "Note that on most platforms, 'rename' is emitted whenever a filename appears or disappears in the directory."

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that works for me.

Please note the listener callback is attached to the `'change'` event
fired by [`fs.FSWatcher`][], but they are not the same thing.
Note that on most platforms, `'rename'` is also emitted when a file is deleted or added.
In other words, it is emitted whenever a filename appears or disappears in the directory.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: add on most platforms here too to be as explicit as possible: In other words, on most platforms, it is emitted...

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

LGTM with a nit

or disappears in the directory.

Also note the listener callback is attached to the `'change'` event fired by
[`fs.FSWatcher`][], but it is not the same thing as the `'change'` value of `eventType`.
Copy link
Member

Choose a reason for hiding this comment

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

nit: long line here.

@silverwind
Copy link
Contributor

Thanks! Landed in b209a6e.

@silverwind silverwind closed this Nov 15, 2016
silverwind pushed a commit that referenced this pull request Nov 15, 2016
'rename' is confusing, and it's not clear what "they" refers to.

Fixes: #9082
PR-URL: #9318
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
addaleax pushed a commit that referenced this pull request Nov 22, 2016
'rename' is confusing, and it's not clear what "they" refers to.

Fixes: #9082
PR-URL: #9318
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
@seishun seishun deleted the rename branch December 6, 2016 10:08
@MylesBorins
Copy link
Contributor

@seishun is this behavior consistent in v4 and v6? Should this be backported?

@seishun
Copy link
Contributor Author

seishun commented Dec 14, 2016

@thealphanerd AFAIK this behavior has been the same since fs.watch was introduced.

MylesBorins pushed a commit that referenced this pull request Dec 21, 2016
'rename' is confusing, and it's not clear what "they" refers to.

Fixes: #9082
PR-URL: #9318
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
MylesBorins pushed a commit that referenced this pull request Dec 21, 2016
'rename' is confusing, and it's not clear what "they" refers to.

Fixes: #9082
PR-URL: #9318
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
@MylesBorins MylesBorins mentioned this pull request Dec 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

watch always fires rename event
6 participants