is-install-needed
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

is-install-needed

GitHub license Build Status Coverage Dependencies

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

Readme

Keywords

none

Package Sidebar

Install

npm i is-install-needed

Weekly Downloads

2

Version

2.0.0

License

ISC

Unpacked Size

216 kB

Total Files

28

Last publish

Collaborators

  • mekwall