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
44 lines (41 loc) • 1.29 kB
JavaScript
import {
checkLockfileSync
} from "./chunk-JV6OSG4M.js";
// src/install.ts
import { execSync } from "node:child_process";
var installStartMessage = "\u{1F4E6} Installing dependencies...";
var installSuccessMessage = "\u2728 \x1B[32mDependencies installed successfully\x1B[0m";
var installErrorMessage = "\u274C \x1B[31mFailed to install dependencies:\x1B[0m";
function installDependencies(packageManager) {
const installCommand = packageManager === "npm" ? "npm install" : packageManager === "yarn" ? "yarn" : "pnpm install";
try {
console.log(installStartMessage);
execSync(installCommand, { stdio: "inherit" });
console.log(installSuccessMessage);
process.exit(0);
} catch (error) {
console.error(installErrorMessage, error);
process.exit(1);
}
}
// src/cli.ts
var syncMessage = "\x1B[35mLockfile has been updated!\x1B[0m";
function init() {
const args = process.argv.slice(2);
const pkgManager = args.find((arg) => arg !== "--install") || "pnpm";
const installFlag = args.includes("--install");
const needSync = checkLockfileSync(pkgManager);
if (needSync) {
if (installFlag) {
installDependencies(pkgManager);
return;
}
console.log(syncMessage);
}
}
init();
export {
init,
syncMessage
};