Created
February 14, 2026 11:56
-
-
Save krutoo/3c8a7a73a7655649837940218fd92067 to your computer and use it in GitHub Desktop.
Get mtime for directory based on contained files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { readdirSync, statSync } from 'node:fs'; | |
| import path from 'node:path'; | |
| export function getMtimeDeep(dirname: string): number { | |
| const files = readdirSync(dirname, { recursive: true }); | |
| let max = 0; | |
| for (const filename of files) { | |
| const stat = statSync(path.join(dirname, filename as string)); | |
| if (stat.mtimeMs > max) { | |
| max = stat.mtimeMs; | |
| } | |
| } | |
| return max; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment