Closed mobiliabrus closed 11 months ago
For most of files, it works greatly. Sometimes, not. Eg, sourceFile.stat.mtimeMs is 1702113370657.8303, and the mtimeMs I got from fs.statSync(targetPath, { bigint: true }) is 1702113370657n.
sourceFile.stat.mtimeMs
1702113370657.8303
mtimeMs
fs.statSync(targetPath, { bigint: true })
1702113370657n
So I tried this.
function hasChanged(sourceFile, targetPath) { if (!fs.existsSync(targetPath)) { return sourceFile; } const targetStat = fs.statSync(targetPath); if (sourceFile.stat && sourceFile.stat.mtimeMs - targetStat.mtimeMs > 1) { // 👈 console.log(chalk.green('processing ') + path.basename(targetPath)); return sourceFile; } console.log('ignoring ' + path.basename(targetPath)); }
For most of files, it works greatly. Sometimes, not. Eg,
sourceFile.stat.mtimeMs
is1702113370657.8303
, and themtimeMs
I got fromfs.statSync(targetPath, { bigint: true })
is1702113370657n
.So I tried this.