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

Only one change detected for non-glob patterns with atomic save #141

Closed
julien-f opened this issue Feb 26, 2015 · 11 comments
Closed

Only one change detected for non-glob patterns with atomic save #141

julien-f opened this issue Feb 26, 2015 · 11 comments

Comments

@julien-f
Copy link
Contributor

When the pattern does not contain a glob and the file is saved atomically (copy and move over, like SublimeText does), only the first change is detected.

var gulp = require('gulp');
var watch = require('gulp-watch');

gulp.task('default', function () {
  return watch('foo.txt', {
    verbose: true,
  });
});

If the file is just touched (touch foo.txt) it works normally but if it is replaced (cp foo.txt _tmp && mv -f _tmp foo.txt) then the watch breaks.

If the pattern contains a glob (foo*.txt) then it works as it should.

/cc @es128.

@es128
Copy link
Contributor

es128 commented Feb 26, 2015

Well, the difference isn't between globs and non-globs, it's between watching a directory (globs effectively watch a directory with a filter) and watching an individual file.

I'm assuming you're encountering this on Linux?

@julien-f
Copy link
Contributor Author

Indeed, Debian 8.

@julien-f
Copy link
Contributor Author

So, do you consider it as a bug or should I use a work around?

@es128
Copy link
Contributor

es128 commented Feb 26, 2015

Probably a bug. Need to investigate

But by all means - use a workaround for now since it's easy.

@julien-f
Copy link
Contributor Author

For information, I think the best workaround is to use a character class for a single character:

var gulp = require('gulp');
var watch = require('gulp-watch');

gulp.task('default', function () {
  return watch('[f]oo.txt', {
    verbose: true,
  });
});

julien-f added a commit to vatesfr/xen-orchestra that referenced this issue Mar 4, 2015
@DarkPark
Copy link

DarkPark commented Sep 7, 2015

the problem is still exist
version: 4.3.5
gulp-watch detects only the first single file change and nothing after it

// less
watch([
    path.join(global.paths.app, 'less', '**', '*.{less,js}'),   // <--- all these files changes are well detected
    path.join(global.paths.config, 'metrics.js')   // <--- only the first change
], function () {
    gulp.start('less:develop');
});

@es128
Copy link
Contributor

es128 commented Sep 7, 2015

Crossref paulmillr/chokidar#237

@DarkPark
Copy link

DarkPark commented Sep 7, 2015

I see
but the suggested solution is difficult to call elegant

@es128
Copy link
Contributor

es128 commented Sep 7, 2015

Nobody called it elegant. It's a thankfully simple, albeit ugly, workaround for a bug that hasn't been squished yet.

@DarkPark
Copy link

DarkPark commented Sep 7, 2015

anyway thanks for pointing me in the right direction

@UltCombo
Copy link
Collaborator

This seems to have been fixed upstream.

Please comment/reopen if you are still experiencing this issue.

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

No branches or pull requests

4 participants