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

→ 0.7.1, restart watching gobblefile if it's deleted/moved away #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

IvanSanchez
Copy link
Member

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.


if ( type === 'delete' ) {
logger.info({ code: 'GOBBLEFILE_DELETED' });
return setTimeout( watch, 2000 );
Copy link
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

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.

2 participants