sindresorhus / gulp-changed

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

compareLastModifiedTime does not work #77

Closed sygnas closed 5 years ago

sygnas commented 5 years ago

compareLastModifiedTime does not work properly in gulp4 environment.

This is a display of the comparison content.

process.stdout.write(sourceFile.stat.mtimeMs + ' > ' + targetStat.mtimeMs + "\n");

if (sourceFile.stat && sourceFile.stat.mtimeMs > targetStat.mtimeMs) {
 ...
1560691395680.4546 > 1560691395680

The original file mtimeMs has decimal places, so the file will be copied no matter how many times it is executed.

It worked fine by adding Math.floor ().

if (sourceFile.stat && Math.floor(sourceFile.stat.mtimeMs) > Math.floor(targetStat.mtimeMs)) {
Bub-la-bub commented 5 years ago

@sygnas++ I've also noticed this wasn't working after upgrading to gulp4.

skunkbad commented 5 years ago

Same issue Ubuntu 18.04 Node 10.16.0 Gulp 4.0.2 gulp-changed 4.0.0

Easily debugged:

console.log(targetStat);
console.log({
    'source': sourceFile.stat.mtimeMs,
    'target': targetStat.mtimeMs
});
agarzola commented 5 years ago

78 fixes the issue when I test it locally on a project that has this issue.