→ 0.7.1, restart watching gobblefile if it's deleted/moved away#22
Open
IvanSanchez wants to merge 1 commit intomasterfrom
Open
→ 0.7.1, restart watching gobblefile if it's deleted/moved away#22IvanSanchez wants to merge 1 commit intomasterfrom
IvanSanchez wants to merge 1 commit intomasterfrom
Conversation
|
|
||
| if ( type === 'delete' ) { | ||
| logger.info({ code: 'GOBBLEFILE_DELETED' }); | ||
| return setTimeout( watch, 2000 ); |
Contributor
There was a problem hiding this comment.
what about a setInterval that gets cancelled once the file exists again? Or, equivalently...
function checkGobbleFileExists () {
fs.exists( gobblefile, exists => exists ? restart() : setTimeout( checkGobbleFileExists, 100 ) );
}
// ...
if ( type === 'delete' ) {
logger.info({ code: 'GOBBLEFILE_DELETED' });
return setTimeout( checkGobbleFileExists, 100 );
}That way you don't have to wait 2 seconds each time the editor saves. Thoughts?
Member
Author
There was a problem hiding this comment.
I don't have a strong opinion about this particular bit. Waiting 2 seconds works reliably for my use case, but I can see the appeal of checking for the gobblefile in a loop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes gobblejs/gobble#110
The root cause was my text editor (kate): when making modifications to a file, it moves (renames) the existing file (
gobblefile.js) into a backup file (gobblefile.js~), and re-creates a file with the original name. Pathwatcher interprets that as deleting the file.