sindresorhus / gulp-changed

Only pass through changed files
MIT License
742 stars 44 forks source link

when new files, it should be runing twice? #51

Closed wenzi0github closed 5 years ago

wenzi0github commented 8 years ago

When I first run the gulp-changed in my project or I add new files in my project, the new files wouldn't pass though gulp-changed, beause

fs.stat(targetPath, function (err, targetStat) {  // targetPath isn't exist

This problem can be fixed, or I have to require other plugin?

thx

CydGoblin commented 8 years ago

having same problem, new files won't pass

xeonicca commented 8 years ago

I had to write a custom comparison function to address this:

var hasChanged = function(stream, cb, sourceFile, targetPath) {
  try {
    stats = fs.statSync(targetPath); // test if the file exists
    changed.compareSha1Digest(stream, cb, sourceFile, targetPath);
  } catch(e) {
    stream.push(sourceFile);
  }
};
321ckatz123 commented 8 years ago

Is this still an active issue? This worked for me and looking at the code there is a whole section dedicated to ignoring missing files.

function fsOperationFailed(stream, sourceFile, err) {
    if (err) {
        if (err.code !== 'ENOENT') {
            stream.emit('error', new gutil.PluginError('gulp-changed', err, {
                fileName: sourceFile.path
            }));
        }

        stream.push(sourceFile);
    }

    return err;
}
zjr commented 5 years ago

@sindresorhus I'm sure you're busy, just bumping this because I'm not sure if there's a reason you didn't want to include new files (seems like there is?) so not sure if I should PR to "fix" this. Maybe could be optional?

Edit: I think I might have misunderstood and all seems fine.