From e7ada20240c9f8b1501e4f94cb0c28b2811e8eb9 Mon Sep 17 00:00:00 2001 From: starnayuta <58112571+starnayuta@users.noreply.github.com> Date: Fri, 26 Jan 2024 07:32:24 +0900 Subject: [PATCH] docs: update install script to mjs and simplify (#1357) * docs: update install script to mjs and fix CI checks * revert indent * Update how-to.md --------- Co-authored-by: typicode --- docs/how-to.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/how-to.md b/docs/how-to.md index 66f0b870..72ec79d7 100644 --- a/docs/how-to.md +++ b/docs/how-to.md @@ -66,21 +66,23 @@ Modify the `prepare` script to never fail: "prepare": "husky || true" ``` -You'll still get a `command not found` error message in your output which may be confusing. To make it silent, create `.husky/install.js`: +You'll still get a `command not found` error message in your output which may be confusing. To make it silent, create `.husky/install.mjs`: ```js // Skip Husky install in production and CI +import husky from 'husky' + if (process.env.NODE_ENV === 'production' || process.env.CI === '1') { process.exit(0) } -const husky = await import('husky') -husky() + +console.log(husky()) ``` Then, use it in `prepare`: ```json -"prepare": "node .husky/install.js" +"prepare": "node .husky/install.mjs" ``` ## Testing Hooks Without Committing