1
Fork 0
This commit is contained in:
Conduitry 2023-08-13 11:18:04 -04:00
parent d5ab318ff1
commit 6fd540c129

View file

@ -10,17 +10,14 @@ if (process.argv.length < 3) {
function recurse(path) {
const stats = statSync(path);
if (stats.isFile()) {
return stats.mtimeMs;
return stats.mtimeMs / 1000;
}
if (stats.isDirectory()) {
let max = 0;
readdirSync(path).forEach(child => {
max = Math.max(max, recurse(path + '/' + child));
});
const max = readdirSync(path).reduce((max, child) => Math.max(max, recurse(path + '/' + child)), 0);
if (max === 0) {
throw new Error(`Empty directory: ${path}`);
}
utimesSync(path, max / 1000, max / 1000);
utimesSync(path, max, max);
return max;
}
throw new Error(`Unexpected type: ${path}`);