Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update install script to mjs and fix CI checks #1357

Merged
merged 3 commits into from
Jan 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions docs/how-to.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down