is-install-needed
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 and pnpm.
Installation
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.
Usage
CLI
$ is-install-needed
It will automatically look for yarn.lock, package-lock.json and shrinkwrap.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 |
Programmatic API
Check if install is needed
import { isInstallNeeded } from 'is-install-needed';
async () => {
const isNeeded = await isInstallNeeded();
if (result) {
console.error('You need to run install');
process.exit(1);
}
};
Find closest lock file
import { findClosestLockfile } from 'is-install-needed';
async () => {
const lockfile = await findClosestLockfile();
console.log(lockfile);
};