A simple devtool that tells you if you need to run install or not. It does so by checking if the lock file of your preferred package manager has changed. Supports the most popular package managers out there: npm, yarn (v1 and v2) and pnpm.
Install the is-install-needed
package with your preferred package manager.
Add is-install-needed --postinstall
to your postscript to automatically write a check file after install.
$ is-install-needed
It will automatically look for yarn.lock, package-lock.json and pnpm-lock.yaml when no preferred package manager is provided.
Flag | Available options | Description |
---|---|---|
--prefer |
npm, yarn or pnpm | Preferred package manager |
--cwd |
<path> | Current working directory |
--postinstall |
Postinstall script |
import { isInstallNeeded } from "is-install-needed";
async () => {
const isNeeded = await isInstallNeeded();
if (result) {
console.error("You need to run install");
process.exit(1);
}
};
import { findClosestLockfile } from "is-install-needed";
async () => {
const lockfile = await findClosestLockfile();
console.log(lockfile); // > /path/to/package/.yarn.lock
};