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
22 lines (20 loc) • 624 B
JavaScript
import { execSync } from "node:child_process";
//#region src/index.ts
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 {
return execSync("git diff --name-only ORIG_HEAD HEAD", { encoding: "utf-8" }).includes(lockfile);
} catch {
console.log("Error checking lockfile, please check manually.");
return false;
}
}
//#endregion
export { checkLockfileSync, getLockfilePath };