assert-pm

1.0.2 • Public • Published

assert-pm

yarn and npm have started to diverge in feature set. For example yarn introduced workspaces, which do not work with npm (yet).

To avoid contributors accidentally using the "wrong" package manager and getting hard to debug errors, you can use assert-pm as a postinstall script. It'll cause the installation to fail and warn the user.

Installation

yarn add --dev assert-pm
npm install --dev assert-pm

Usage

If you are managing your packages with workspaces, you can add it to your parent package.json as postinstall script. Make sure to not add it to packages you do publish as this script will also be run upon installation by users.

 "scripts": {
    "postinstall": "assert-pm yarn --message"
  }

If anyone now runs

npm install

they will get an error:

 pmtest@1.0.0 postinstall
> assert-pm yarn

Please use yarn.
npm ERR! code ELIFECYCLE

Options

assert-pm package-manager --message "We are managing our packages using yarn workspaces. Therefore this project requires yarn to install packages."

Readme

Keywords

none

Package Sidebar

Install

npm i assert-pm

Weekly Downloads

0

Version

1.0.2

License

MIT

Last publish

Collaborators

  • robin-drexler