From 50f7d1b2f1a8866a7e083221feab0630a61db1d1 Mon Sep 17 00:00:00 2001 From: typicode Date: Sun, 20 Feb 2022 23:56:02 +0100 Subject: [PATCH] docs: recommend prepare for npm/pnpm --- README.md | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index eaaf06d..174a2eb 100644 --- a/README.md +++ b/README.md @@ -2,32 +2,24 @@ > `pinst` lets you have `postinstall` hook that runs only in dev 🍺 -This can be useful if you want to automatically run commands just after `npm install`, but don't want your package users to be affected. +__Important__ if your project is using npm or pnpm, you can achieve the desired effect by setting a `prepare` hook instead. `pinst` is mainly useful for Yarn 2+ since it doesn't support `prepare` hook. See https://yarnpkg.com/advanced/lifecycle-scripts ## Usage -```sh -$ npm install pinst --save-dev -``` - ```js // package.json { "scripts": { "postinstall": "", - "prepublishOnly": "pinst --disable", - "postpublish": "pinst --enable" + "prepack": "pinst --disable", + "postpack": "pinst --enable" } } ``` -```sh -$ npm publish -``` - -_On `prepublishOnly`, `postinstall` will be renamed to `_postinstall` (disabled)_ +_On `prepack`, `postinstall` will be renamed to `_postinstall` (disabled)_ -_On `postpublish`, it will be renamed back to `postinstall` (enabled)_ +_On `postpack`, it will be renamed back to `postinstall` (enabled)_ ## CLI @@ -39,15 +31,6 @@ _On `postpublish`, it will be renamed back to `postinstall` (enabled)_ --silent, -s ``` -## Try it - -To test that everything works without actually publishing your package, you can manually run the following commands: - -```sh -$ npm run prepublishOnly -$ npm run postpublish -``` - ## Tips By inverting commands, you can also use `pinst` to enable `postinstall` for your users only and not yourself.