Skip to content

A simple devtool that tells you if you need to run install or not

License

Notifications You must be signed in to change notification settings

mekwall/is-install-needed

Repository files navigation

is-install-needed

license npm dependencies types build coverage quality

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.

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 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

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); // > /path/to/package/.yarn.lock
};