Every now and then I need a little tool which takes a snapshot of a folder and compares it to an older one. Imagine we program a build/bundler tool which uses this technqiue to ensure integrity after changes to the core.
snapshot-dir exports four functions to generate and compare snapshots.
snapshot(path: string): Promise<SnapshotResult>
Generates a snapshot from a given path
. The result is an object with filenames as keys and hashs as values.
snapshotCompare(path: string, currentSnap: SnapshotResult): Promise<IDiff>
Compares a given path
with a given currentSnap
and returns a deep-diff result object, which is undefined for no diff or a changeset.
Same as snapshot
but sync.
Same as snapshotCompare
but sync.