UNPKG

lockfile-sync-check

Version:

A command-line tool to check if your package manager's lockfile is in sync with the latest changes in your Git repository

30 lines (28 loc) 689 B
// src/index.ts import { execSync } from "node:child_process"; function getLockfilePath(packageManager) { switch (packageManager) { case "pnpm": return "pnpm-lock.yaml"; case "yarn": return "yarn.lock"; case "npm": return "package-lock.json"; } } function checkLockfileSync(packageManager) { const lockfile = getLockfilePath(packageManager); try { const diffOutput = execSync("git diff --name-only ORIG_HEAD HEAD", { encoding: "utf-8" }); return diffOutput.includes(lockfile); } catch { console.log("Error checking lockfile, please check manually."); return false; } } export { getLockfilePath, checkLockfileSync };