Created
July 26, 2025 18:59
-
-
Save artalar/0f4abc938175005efaa799d940b24aea to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env node | |
import { execSync } from "child_process" | |
import { createHash } from "crypto" | |
import { mkdir, readFile, writeFile } from "fs/promises" | |
const cacheDir = "./node_modules/.cache" | |
const cachePath = `${cacheDir}/deps_check_lock_hash.txt` | |
await mkdir(cacheDir, { recursive: true }).catch(() => {}) | |
const lockContent = await readFile("package-lock.json", "utf-8").catch(() => "") | |
const lockHash = createHash("sha256").update(lockContent).digest("hex") | |
const lockHashCache = await readFile(cachePath, "utf-8").catch(() => "") | |
if (lockHashCache !== lockHash) { | |
execSync("npm i", { stdio: "inherit" }) | |
await writeFile(cachePath, lockHash) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment