feat: adding linter for commits

This commit is contained in:
Carlos Gutierrez
2021-11-22 09:39:27 -06:00
commit 2c7c117aa1
3093 changed files with 1215197 additions and 0 deletions

30
node_modules/husky/.husky/_/husky.sh generated vendored Normal file
View File

@ -0,0 +1,30 @@
#!/bin/sh
if [ -z "$husky_skip_init" ]; then
debug () {
[ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1"
}
readonly hook_name="$(basename "$0")"
debug "starting $hook_name..."
if [ "$HUSKY" = "0" ]; then
debug "HUSKY env variable is set to 0, skipping hook"
exit 0
fi
if [ -f ~/.huskyrc ]; then
debug "sourcing ~/.huskyrc"
. ~/.huskyrc
fi
export readonly husky_skip_init=1
sh -e "$0" "$@"
exitCode="$?"
if [ $exitCode != 0 ]; then
echo "husky - $hook_name hook exited with code $exitCode (error)"
exit $exitCode
fi
exit 0
fi

310
node_modules/husky/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,310 @@
# CHANGELOG
⚠️ __Changes for `>=3` can now be found in https://github.com/typicode/husky/releases__
## 3.0.0
* Fix HUSKY_SKIP_INSTALL=1 not skipping install
* __Breaking change__ husky requires now Git `>= 2.13.2`. If you're already using husky `v2` and don't use an old version of Git, you can safely upgrade.
## 2.7.0
Due to issues with Git `< 2.13.2`, this version is a rollback and is the same as husky `v2.4.1`. Changes introduced in `v2.5.0` and `v2.6.0` will be published in `v3.0.0`.
## 2.6.0
* Optional `HUSKY_USE_YARN` setting to use Yarn to run Husky
* Add more debug information
* Show a warning for Node `<= 8.6.0`
__Deprecated__
## 2.5.0
* Use more accurate git hooks directory resolution
* Add `CWD` in debug messages
__Deprecated__
## 2.4.1
* Fix husky crash on install/uninstall with very old Node versions
## 2.4.0
* Add `HUSKY_SKIP_HOOKS` to skip all hooks
## 2.3.0
* Make `HUSKY_DEBUG=1` effective like `HUSKY_DEBUG=true`
* Refactor script to point to `run-node/run-node` rather than `.bin/run-node`
## 2.2.0
* Improve Git worktree support
## 2.1.0
* Improve shell script portability by using `.` rather than `source`
## 2.0.0
* Update dependencies
* Update messages
* __Breaking change__ drop `Node 6` support
## 1.3.1
* Update docs
* Upgrade `is-ci` and support more CIs
* Disable `1.3.0` change related to `stdin` due to a bug on Windows
## 1.3.0
* Enable `stdin` if hook is running in a terminal
## 1.2.1
* Fix don't fail if directory in project contains whitespace
## 1.2.0
* Add comments to generated hooks to specify which package has installed husky and when
## 1.1.4
* Upgrade `execa` dependency
## 1.1.3
* Fix don't fail if `package.json` doesn't exist
## 1.1.2
* Add debug message
## 1.1.1
* Check `HUSKY_SKIP_INSTALL` value first before checking if `.git` exists
* Check Node version before running hooks
## 1.1.0
* Create `.git/hooks` if it doesn't exist
## 1.0.1
* Various `husky-upgrade` changes ([#362](https://github.com/typicode/husky/pull/362), [#360](https://github.com/typicode/husky/pull/360), [#359](https://github.com/typicode/husky/pull/359))
## 1.0.0
After a year of pre-releases and a complete rewrite, this marks the first stable release of husky 🐶🎉.
### Notable changes
Below you'll find consolidated changes since `0.14.3`. There's no change in code between `1.0.0-rc.15` and `1.0.0`.
* Hooks
* Add `sendemail-validate` hook
* Config
* Move hooks config from `scripts` field to `husky` field
* Prefer raw names for hooks (e.g. `pre-commit` rather than `precommit`)
* Support `.huskyrc` config
* Package managers
* Support environments where [yarn](https://github.com/yarnpkg/yarn/) is the only package manager installed
* Support [pnpm](https://github.com/pnpm/pnpm) package manager
* Environment variables
* Add `HUSKY_SKIP_INSTALL` environment variable for skipping git hooks installation
* Add `HUSKY_GIT_STDIN` environment variable for `pre-push`, `pre-receive`, `post-receive` and `post-rewrite` to access arguments passed by Git via stdin
* Rename `GIT_PARAMS` to `HUSKY_GIT_PARAMS`
* Messages
* Add many more messages in case of errors
* Add [please-upgrade-node](https://github.com/typicode/please-upgrade-node) message if using with unsupported Node version
* Make `--no-verify` message more accurate and only show it for hooks that can be skipped
* Upgrade
* Add `husky-upgrade` command to automatically migrate hooks in `package.json`
* Add deprecation warning for hooks that are still defined in `scripts`
* Other
* Drop `Node 4` support
* Drop integrated `nvm` support (see Node version management in docs)
### Credits
Huge thanks to all the Contributors and [Patreon Supporters](https://thanks.typicode.com)! 🙏
## 1.0.0-rc.15
* Update docs
## 1.0.0-rc.14
* Make `--no-verify` message more accurate and only show it for hooks that can be skipped
* Improve error messages
## 1.0.0-rc.13
* Show a message when Node can't be found in PATH
## 1.0.0-rc.12
* Fix exit code when used with unsupported Node version
* Update dependencies
## 1.0.0-rc.11
* Show a message instead of crashing if Node version is unsupported by Husky
## 1.0.0-rc.10
* Fix `HUSKY_GIT_PARAMS` containing only the first Git param
## 1.0.0-rc.9
* If `node_modules/husky` is missing, show message but do not crash
* Remove and upgrade some `dependencies`
## 1.0.0-rc.8
* Add `HUSKY_GIT_STDIN` environment variable for `pre-push`, `pre-receive`, `post-receive` and `post-rewrite` to access arguments passed by Git via stdin.
## 1.0.0-rc.7
* Update `cosmiconfig` dependency
* Fix `package.json` normalization error
## 1.0.0-rc.6
* Fix install error with `pnpm`
## 1.0.0-rc.5
* Auto migrate `yorkie` hooks
## 1.0.0-rc.4
* Re-enable Git submodule and worktree support
## 1.0.0-rc.3
* Re-enable subdirectory support
## 1.0.0-rc.2
* Upgrade `run-node` dependency
## 1.0.0-rc.1
* Namespace environment variable created by husky
* `GIT_PARAMS` becomes `HUSKY_GIT_PARAMS`
* Starting also with `1.0.0` versioning
## 0.15.0-rc.13
* Revert `GIT_STDIN` for the moment. Needs more testing.
`rc.10`, `rc.11` and `rc.12` are broken for some GUI clients due to `read` command
## 0.15.0-rc.9
* Handle case where `.git/hooks` directory doesn't exit
## 0.15.0-rc.8
* Handle case where `v0.14` git hooks wouldn't have been uninstalled
## 0.15.0-rc.7
* Move `postinstall` script to `install`
* Fix line ending error when running `upgrader` from OS X/Linux
## 0.15.0-rc.6
* Fix `[[` error
## 0.15.0-rc.5
* Fix error with GitHub Desktop on Windows
## 0.15.0-rc.4
* Catch error if `git` command fails
## 0.15.0-rc.3
* Fix `husky-upgrade`
* Drop `Node 4` support
## 0.15.0-rc.2
* Fix install error
## 0.15.0-rc.1
* `sendemail-validate` hook [#173](https://github.com/typicode/husky/pull/173)
* `HUSKY_SKIP_INSTALL` environment variable for skipping git hooks installation [#178](https://github.com/typicode/husky/pull/178)
* `.huskyrc` config [#209](https://github.com/typicode/husky/pull/209)
* [`pnpm`](https://github.com/pnpm/pnpm) support
* Support environments where `yarn` is the only package manager installed
* Move config from `scripts` field to `husky` field
* Prefer raw names for Git hooks (`pre-commit` rather than `precommit`)
* Drop integrated `nvm` support
* To ease upgrade:
* Provide `husky-upgrade` command
* Add deprecation warning for hooks that are defined in `scripts` (but still run them)
## 0.14.3
* Fix handle space in `PATH` [#150](https://github.com/typicode/husky/pull/114)
## 0.14.2
* Fix handle space in `HOME`
## 0.14.1
* Fix Git hooks install on Windows
* Fix hook script when `nvm` was installed with Brew
## 0.14.0
* Fix `npm@5` `Error: Cannot find module` warning when uninstalling
* Drop `Node 0.12` support
* Don't reload `nvm` if it's already in `PATH`
* Add Git worktree support [#114](https://github.com/typicode/husky/pull/114)
* Hide irrelevant `--no-verify` message for `prepare-commit-msg` [#137](https://github.com/typicode/husky/issues/137)
## 0.13.4
* Add Node version to husky output
## 0.13.3
* Revert `Fixes issue with OS X + brew where nvm was loaded even when npm was already present` that was introduced in `v0.13.0` as it was preventing Husky to load `nvm` in some cases [#106](https://github.com/typicode/husky/issues/106)
## 0.13.2
* Fixes issue [#103](https://github.com/typicode/husky/issues/103)
## 0.13.1
* Makes it easier for projects to transition from [ghooks](https://github.com/gtramontina/ghooks) by detecting ghooks installed scripts and automatically migrating them
## 0.13.0
* Makes `husky` a little less verbose by default
* Fixes issue with `OS X + brew` where `nvm` was loaded even when `npm` was already present
* Fixes issue with Git `v1.9` on Windows
* Prevents Git hooks being installed when husky is in a sub `node_modules` directory (i.e. `./node_modules/A/node_modules/husky`)
## 0.12.0
* Adds Git submodule support
* Adds Cygwin support
* Improves edge cases support (`.git` not found and `git` not in `PATH`)
* If `npm` is already present in path, doesn't load `nvm` default or `.nvmrc` version, which makes things faster in terminal. In GUI apps, the behavior is unchanged.

21
node_modules/husky/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 - present
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

360
node_modules/husky/README.md generated vendored Normal file
View File

@ -0,0 +1,360 @@
# Husky
[![Financial Contributors on Open Collective](https://opencollective.com/husky/all/badge.svg?label=financial+contributors)](https://opencollective.com/husky) [![](https://img.shields.io/npm/dm/husky.svg?style=flat)](https://www.npmjs.org/package/husky) [![Mac/Linux Build Status](https://img.shields.io/travis/typicode/husky/master.svg?label=Mac%20OSX%20%26%20Linux)](https://travis-ci.org/typicode/husky) [![Windows Build status](https://img.shields.io/appveyor/ci/typicode/husky/master.svg?label=Windows)](https://ci.appveyor.com/project/typicode/husky)
> Git hooks made easy
Husky can prevent bad `git commit`, `git push` and more 🐶 _woof!_
**Announcement: Husky v5 has been published, to view v5 docs click [here](https://typicode.github.io/husky).**
**Note to npm v7 users**: if hooks aren't being installed with npm `v7`, check that your version is at least `v7.1.2`.
## Install
This will install husky v4.
```sh
npm install husky --save-dev
```
```js
// package.json
{
"husky": {
"hooks": {
"pre-commit": "npm test",
"pre-push": "npm test",
"...": "..."
}
}
}
```
```sh
git commit -m 'Keep calm and commit'
```
_Existing hooks are kept. Requires Node `>= 10` and Git `>= 2.13.0`._
## Reinstall
If Husky is already in your `node_modules` or `pnp.js` (Yarn 2) and you want to reinstall hooks, you can run `npm rebuild` or `yarn rebuild`.
## Uninstall
```sh
npm uninstall husky
```
_Git hooks installed by husky will be removed._
## Sponsors
### Companies (\$100+/month)
<!-- for (let i = 0; i < 40; i++) console.log(`[![Husky Sponsor](https://opencollective.com/husky/backer/${i}/avatar)](https://opencollective.com/husky/backer/${i}/website)`) -->
Does your company use Husky? Ask your manager or marketing team if your company would be interested in supporting this project.
<a href="https://opencollective.com/husky/tiers/sponsor/0/website"><img src="https://opencollective.com/husky/tiers/sponsor/0/avatar.svg" height="60px"></a>
<a href="https://opencollective.com/husky/tiers/sponsor/1/website"><img src="https://opencollective.com/husky/tiers/sponsor/1/avatar.svg" height="60px"></a>
<a href="https://opencollective.com/husky/tiers/sponsor/2/website"><img src="https://opencollective.com/husky/tiers/sponsor/2/avatar.svg" height="60px"></a>
<a href="https://opencollective.com/husky/tiers/sponsor/3/website"><img src="https://opencollective.com/husky/tiers/sponsor/3/avatar.svg" height="60px"></a>
<a href="https://opencollective.com/husky/tiers/sponsor/4/website"><img src="https://opencollective.com/husky/tiers/sponsor/4/avatar.svg" height="60px"></a>
<a href="https://opencollective.com/husky/tiers/sponsor/5/website"><img src="https://opencollective.com/husky/tiers/sponsor/5/avatar.svg" height="60px"></a>
<a href="https://opencollective.com/husky/tiers/sponsor/6/website"><img src="https://opencollective.com/husky/tiers/sponsor/6/avatar.svg" height="60px"></a>
<a href="https://opencollective.com/husky/tiers/sponsor/7/website"><img src="https://opencollective.com/husky/tiers/sponsor/7/avatar.svg" height="60px"></a>
<a href="https://opencollective.com/husky/tiers/sponsor/8/website"><img src="https://opencollective.com/husky/tiers/sponsor/8/avatar.svg" height="60px"></a>
<a href="https://opencollective.com/husky/tiers/sponsor/9/website"><img src="https://opencollective.com/husky/tiers/sponsor/9/avatar.svg" height="60px"></a>
### Individuals
Find Husky helpful? Become a backer and show your appreciation with a monthly donation on [Open Collective](https://opencollective.com/husky). You can also tip with a one-time donation.
[![Husky Sponsor](https://opencollective.com/husky/backer/0/avatar)](https://opencollective.com/husky/backer/0/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/1/avatar)](https://opencollective.com/husky/backer/1/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/2/avatar)](https://opencollective.com/husky/backer/2/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/3/avatar)](https://opencollective.com/husky/backer/3/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/4/avatar)](https://opencollective.com/husky/backer/4/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/5/avatar)](https://opencollective.com/husky/backer/5/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/6/avatar)](https://opencollective.com/husky/backer/6/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/7/avatar)](https://opencollective.com/husky/backer/7/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/8/avatar)](https://opencollective.com/husky/backer/8/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/9/avatar)](https://opencollective.com/husky/backer/9/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/10/avatar)](https://opencollective.com/husky/backer/10/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/11/avatar)](https://opencollective.com/husky/backer/11/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/12/avatar)](https://opencollective.com/husky/backer/12/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/13/avatar)](https://opencollective.com/husky/backer/13/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/14/avatar)](https://opencollective.com/husky/backer/14/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/15/avatar)](https://opencollective.com/husky/backer/15/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/16/avatar)](https://opencollective.com/husky/backer/16/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/17/avatar)](https://opencollective.com/husky/backer/17/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/18/avatar)](https://opencollective.com/husky/backer/18/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/19/avatar)](https://opencollective.com/husky/backer/19/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/20/avatar)](https://opencollective.com/husky/backer/20/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/21/avatar)](https://opencollective.com/husky/backer/21/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/22/avatar)](https://opencollective.com/husky/backer/22/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/23/avatar)](https://opencollective.com/husky/backer/23/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/24/avatar)](https://opencollective.com/husky/backer/24/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/25/avatar)](https://opencollective.com/husky/backer/25/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/26/avatar)](https://opencollective.com/husky/backer/26/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/27/avatar)](https://opencollective.com/husky/backer/27/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/28/avatar)](https://opencollective.com/husky/backer/28/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/29/avatar)](https://opencollective.com/husky/backer/29/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/30/avatar)](https://opencollective.com/husky/backer/30/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/31/avatar)](https://opencollective.com/husky/backer/31/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/32/avatar)](https://opencollective.com/husky/backer/32/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/33/avatar)](https://opencollective.com/husky/backer/33/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/34/avatar)](https://opencollective.com/husky/backer/34/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/35/avatar)](https://opencollective.com/husky/backer/35/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/36/avatar)](https://opencollective.com/husky/backer/36/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/37/avatar)](https://opencollective.com/husky/backer/37/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/38/avatar)](https://opencollective.com/husky/backer/38/website)
[![Husky Sponsor](https://opencollective.com/husky/backer/39/avatar)](https://opencollective.com/husky/backer/39/website)
GitHub sponsors can be viewed on my [profile](https://github.com/typicode). All past and current Open Collective sponsors can be viewed on [Husky's Open Collective](https://opencollective.com/husky).
## Used by
- [webpack](https://github.com/webpack/webpack)
- [babel](https://github.com/babel/babel)
- [create-react-app](https://github.com/facebook/create-react-app)
- ... and many other awesome projects
## Guides
<!-- toc -->
- [Upgrading from 0.14](#upgrading-from-014)
- [Supported hooks](#supported-hooks)
- [Access Git params and stdin](#access-git-params-and-stdin)
- [Skip all hooks (rebase)](#skip-all-hooks-rebase)
- [Disable auto-install](#disable-auto-install)
- [CI servers](#ci-servers)
- [Monorepos](#monorepos)
- [Node version managers](#node-version-managers)
- [Local commands (~/.huskyrc)](#local-commands-huskyrc)
- [Multiple commands](#multiple-commands)
- [Troubleshoot](#troubleshoot)
- [Debug messages](#debug-messages)
- [Hooks aren't running](#hooks-arent-running)
- [Commits aren't blocked](#commits-arent-blocked)
- [Commits are slow](#commits-are-slow)
- [Testing husky in a new repo](#testing-husky-in-a-new-repo)
- [ENOENT error 'node_modules/husky/.git/hooks'](#enoent-error-node_moduleshuskygithooks)
<!-- tocstop -->
### Upgrading from 0.14
Run `husky-upgrade` to automatically upgrade your configuration:
```
npx --no-install husky-upgrade
```
You can also do it manually. Move your existing hooks to `husky.hooks` field and use raw Git hooks names. Also, if you were using `GIT_PARAMS` env variable, rename it to `HUSKY_GIT_PARAMS`.
```diff
{
"scripts": {
- "precommit": "npm test",
- "commitmsg": "commitlint -E GIT_PARAMS"
},
+ "husky": {
+ "hooks": {
+ "pre-commit": "npm test",
+ "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
+ }
+ }
}
```
Starting with `1.0.0`, husky can be configured using `.huskyrc`, `.huskyrc.json`, `.huskyrc.yaml`, `.huskyrc.yml`, `.huskyrc.js` or `husky.config.js` file.
```js
// .huskyrc
{
"hooks": {
"pre-commit": "npm test"
}
}
```
### Supported hooks
Husky supports all Git hooks defined [here](https://git-scm.com/docs/githooks). Server-side hooks (`pre-receive`, `update` and `post-receive`) aren't supported.
### Access Git params and stdin
Git hooks can get parameters via command-line arguments and stdin. Husky makes them accessible via `HUSKY_GIT_PARAMS` and `HUSKY_GIT_STDIN` environment variables.
```
"commit-msg": "echo $HUSKY_GIT_PARAMS"
```
### Skip all hooks (rebase)
During a rebase you may want to skip all hooks, you can use `HUSKY_SKIP_HOOKS` environment variable.
```sh
HUSKY_SKIP_HOOKS=1 git rebase ...
```
### Disable auto-install
If you don't want husky to automatically install Git hooks, simply set `HUSKY_SKIP_INSTALL` environment variable.
```sh
HUSKY_SKIP_INSTALL=1 npm install
```
### CI servers
By default, Husky won't install on CI servers.
### Monorepos
If you have a multi-package repository, it's **recommended** to use tools like [lerna](https://github.com/lerna/lerna) and have husky installed ONLY in the root `package.json` to act as the source of truth.
Generally speaking, you should AVOID defining husky in multiple `package.json`, as each package would overwrite previous husky installation.
```sh
.
└── root
├── .git
├── package.json 🐶 # Add husky here
└── packages
├── A
│ └── package.json
├── B
│ └── package.json
└── C
└── package.json
```
```js
// root/package.json
{
"private": true,
"devDependencies": {
"husky": "..."
},
"husky": {
"hooks": {
"pre-commit": "lerna run test"
}
}
}
```
### Node version managers
If you're on Windows, husky will simply use the version installed globally on your system.
For macOS and Linux users:
- if you're running `git` commands in the terminal, husky will use the version defined in your shell `PATH`. In other words, if you're a `nvm` user, husky will use the version that you've set with `nvm`.
- if you're using a GUI client and `nvm`, it may have a different `PATH` and not load `nvm`, in this case the highest `node` version installed by `nvm` will usually be picked. You can also check `~/.node_path` to see which version is used by GUIs and edit if you want to use something else.
### Local commands (~/.huskyrc)
Husky will source `~/.huskyrc` file if it exists before running hook scripts.
You can use it, for example, to load a node version manager or run some `shell` commands before hooks.
```sh
# ~/.huskyrc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
```
### Multiple commands
By design and just like `scripts` defined in `package.json`, husky will run hook scripts as a single command.
```json
"pre-commit": "cmd && cmd"
```
That said, if you prefer to use an array, the recommended approach is to define them in `.huskyrc.js` or `husky.config.js`.
```js
const tasks = (arr) => arr.join(' && ')
module.exports = {
hooks: {
'pre-commit': tasks(['cmd', 'cmd']),
},
}
```
Tools like [npm-run-all](https://github.com/mysticatea/npm-run-all) can help too.
### Troubleshoot
#### Debug messages
`HUSKY_DEBUG=1` can provide additional information when running commands.
```
HUSKY_DEBUG=1 npm install husky --save-dev
HUSKY_DEBUG=1 git commit ...
```
#### Hooks aren't running
Check if hooks were installed. Verify that `.git/hooks/pre-commit` exists and have husky code. It should start with:
```sh
#!/bin/sh
# husky...
```
If not, you may have another Git hooks manager defined in your `package.json` overwriting husky's hooks. Check also the output during install, you should see:
```
husky > Setting up git hooks
husky > Done
```
#### Commits aren't blocked
For a commit to be blocked, `pre-commit` script must exit with a non-zero exit code. If you commit isn't blocked, check your script exit code.
#### Commits are slow
Husky is fast and only adds a few tenth of seconds to commits (`~0.3s` on a low-end PC). So it's most probably related to how many things are done during `pre-commit`. You can often improve this by using cache on your tools (babel, eslint, ...) and using [lint-staged](https://github.com/okonet/lint-staged).
#### Testing husky in a new repo
To isolate your issue, you can also create a new repo:
```sh
mkdir foo && cd foo
git init && npm init -y
npm install husky --save-dev
# Add a failing pre-commit hook to your package.json:
# "pre-commit": "echo \"this should fail\" && exit 1"
# Make a commit
```
#### ENOENT error 'node_modules/husky/.git/hooks'
Verify that your version of Git is `>=2.13.0`.
## See also
- [pkg-ok](https://github.com/typicode/pkg-ok) - Prevents publishing a module with bad paths or incorrect line endings
- [please-upgrade-node](https://github.com/typicode/please-upgrade-node) - Show a message to upgrade Node instead of a stacktrace in your CLIs
- [pinst](https://github.com/typicode/pinst) - dev only postinstall hook
## Patreon
People and companies supporting via Patreon: [thanks](https://thanks.typicode.com)
## License
MIT

21
node_modules/husky/bin/run.js generated vendored Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env node
/* eslint-disable @typescript-eslint/no-var-requires */
const pleaseUpgradeNode = require('please-upgrade-node')
const pkg = require('../package.json')
// Node version isn't supported, skip
pleaseUpgradeNode(pkg, {
message(requiredVersion) {
return (
'Husky requires Node ' +
requiredVersion +
' (runtime: ' +
process.version +
')' +
", can't run Git hook."
)
},
})
// Node version is supported, continue
require('../lib/runner/bin')

24
node_modules/husky/husky.js generated vendored Normal file
View File

@ -0,0 +1,24 @@
/* eslint-disable */
// @ts-ignore
const pleaseUpgradeNode = require('please-upgrade-node')
const pkg = require('./package.json')
// Node version isn't supported, skip install
pleaseUpgradeNode(pkg, {
exitCode: 0,
message: function(requiredVersion) {
return (
'Husky requires Node ' +
requiredVersion +
' (runtime: ' + process.version + ')' +
', skipping Git hooks installation.'
)
}
})
// Node version is supported, continue
try {
require('./lib/installer/bin')
} catch (e) {
console.log('missing lib directory')
}

10
node_modules/husky/lib/checkGitDirEnv.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const debug_1 = require("./debug");
function checkGitDirEnv() {
if (process.env.GIT_DIR) {
debug_1.debug(`GIT_DIR environment variable is set to ${process.env.GIT_DIR}`);
debug_1.debug(`If you're getting "fatal: not a git repository" errors, check GIT_DIR value`);
}
}
exports.checkGitDirEnv = checkGitDirEnv;

8
node_modules/husky/lib/debug.js generated vendored Normal file
View File

@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function debug(...args) {
if (['1', 'true'].includes(process.env.HUSKY_DEBUG || '')) {
console.log('husky:debug', ...args);
}
}
exports.debug = debug;

12
node_modules/husky/lib/getConf.js generated vendored Normal file
View File

@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const cosmiconfig_1 = require("cosmiconfig");
function getConf(dir) {
const explorer = cosmiconfig_1.cosmiconfigSync('husky');
const { config = {} } = explorer.search(dir) || {};
const defaults = {
skipCI: true,
};
return Object.assign(Object.assign({}, defaults), config);
}
exports.getConf = getConf;

93
node_modules/husky/lib/installer/bin.js generated vendored Normal file
View File

@ -0,0 +1,93 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = __importDefault(require("chalk"));
const ci_info_1 = require("ci-info");
const path_1 = __importDefault(require("path"));
const pkg_dir_1 = __importDefault(require("pkg-dir"));
const which_pm_runs_1 = __importDefault(require("which-pm-runs"));
const checkGitDirEnv_1 = require("../checkGitDirEnv");
const debug_1 = require("../debug");
const _1 = require("./");
const gitRevParse_1 = require("./gitRevParse");
const checkGitVersion_1 = require("./checkGitVersion");
// Skip install if HUSKY_SKIP_INSTALL is true
function checkSkipInstallEnv() {
if (['1', 'true'].includes(process.env.HUSKY_SKIP_INSTALL || '')) {
console.log('HUSKY_SKIP_INSTALL is set to true,', 'skipping Git hooks installation.');
process.exit(0);
}
}
function getDirs(cwd) {
const { prefix, gitCommonDir } = gitRevParse_1.gitRevParse(cwd);
debug_1.debug('Git rev-parse command returned:');
debug_1.debug(` --git-common-dir: ${gitCommonDir}`);
debug_1.debug(` --show-prefix: ${prefix}`);
const absoluteGitCommonDir = path_1.default.resolve(cwd, gitCommonDir);
// Prefix can be an empty string
const relativeUserPkgDir = prefix || '.';
return { relativeUserPkgDir, absoluteGitCommonDir };
}
// Get INIT_CWD env variable
function getInitCwdEnv() {
const { INIT_CWD } = process.env;
if (INIT_CWD === undefined) {
const { name, version } = which_pm_runs_1.default();
throw new Error(`INIT_CWD is not set, please check that your package manager supports it (${name} ${version})
Alternatively, you could set it manually:
INIT_CWD="$(pwd)" npm install husky --save-dev
Or upgrade to husky v5`);
}
debug_1.debug(`INIT_CWD is set to ${INIT_CWD}`);
return INIT_CWD;
}
function getUserPkgDir(dir) {
const userPkgDir = pkg_dir_1.default.sync(dir);
if (userPkgDir === undefined) {
throw new Error([
`Can't find package.json in ${dir} directory or parents`,
'Please check that your project has a package.json or create one and reinstall husky.',
].join('\n'));
}
return userPkgDir;
}
function run() {
const action = process.argv[2];
try {
console.log('husky > %s git hooks', action === 'install' ? 'Setting up' : 'Uninstalling');
debug_1.debug(`Current working directory is ${process.cwd()}`);
if (action === 'install') {
checkSkipInstallEnv();
checkGitVersion_1.checkGitVersion();
}
const INIT_CWD = getInitCwdEnv();
const userPkgDir = getUserPkgDir(INIT_CWD);
checkGitDirEnv_1.checkGitDirEnv();
const { absoluteGitCommonDir, relativeUserPkgDir } = getDirs(userPkgDir);
if (action === 'install') {
const { name: pmName } = which_pm_runs_1.default();
debug_1.debug(`Package manager: ${pmName}`);
_1.install({
absoluteGitCommonDir,
relativeUserPkgDir,
userPkgDir,
pmName,
isCI: ci_info_1.isCI,
});
}
else {
_1.uninstall({ absoluteGitCommonDir, userPkgDir });
}
console.log(`husky > Done`);
}
catch (err) {
console.log(chalk_1.default.red(err.message.trim()));
debug_1.debug(err.stack);
console.log(chalk_1.default.red(`husky > Failed to ${action}`));
}
}
run();

19
node_modules/husky/lib/installer/checkGitVersion.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const cp = require("child_process");
const find_versions_1 = __importDefault(require("find-versions"));
const compare_versions_1 = __importDefault(require("compare-versions"));
function checkGitVersion() {
const { status, stderr, stdout } = cp.spawnSync('git', ['--version']);
if (status !== 0) {
throw new Error(`git --version command failed. Got ${String(stderr)}.`);
}
const [version] = find_versions_1.default(String(stdout));
if (compare_versions_1.default(version, '2.13.0') === -1) {
throw new Error(`Husky requires Git >=2.13.0. Got v${version}.`);
}
}
exports.checkGitVersion = checkGitVersion;

14
node_modules/husky/lib/installer/getBanner.js generated vendored Normal file
View File

@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
const read_pkg_1 = require("../read-pkg");
function getBanner() {
const pkgHomepage = process.env.npm_package_homepage;
const pkgDirectory = process.env.PWD;
const { homepage: huskyHomepage, version: huskyVersion } = read_pkg_1.readPkg(path.join(__dirname, '../..'));
const createdAt = new Date().toLocaleString();
return `# Created by Husky v${huskyVersion} (${huskyHomepage})
# At: ${createdAt}
# From: ${pkgDirectory} (${pkgHomepage})`;
}
exports.getBanner = getBanner;

23
node_modules/husky/lib/installer/gitRevParse.js generated vendored Normal file
View File

@ -0,0 +1,23 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const child_process_1 = __importDefault(require("child_process"));
const slash_1 = __importDefault(require("slash"));
function gitRevParse(cwd = process.cwd()) {
// https://github.com/typicode/husky/issues/580
// https://github.com/typicode/husky/issues/587
const { status, stderr, stdout } = child_process_1.default.spawnSync('git', ['rev-parse', '--show-prefix', '--git-common-dir'], { cwd });
if (status !== 0) {
throw new Error(`git rev-parse command failed. Got ${String(stderr)}`);
}
const [prefix, gitCommonDir] = stdout
.toString()
.split('\n')
.map((s) => s.trim())
// Normalize for Windows
.map(slash_1.default);
return { prefix, gitCommonDir };
}
exports.gitRevParse = gitRevParse;

88
node_modules/husky/lib/installer/hooks.js generated vendored Normal file
View File

@ -0,0 +1,88 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const path = require("path");
const is_1 = require("./is");
const getBanner_1 = require("./getBanner");
exports.huskyIdentifier = '# husky';
function getHookScript() {
return `#!/bin/sh
${exports.huskyIdentifier}
${getBanner_1.getBanner()}
. "$(dirname "$0")/husky.sh"
`;
}
exports.getHookScript = getHookScript;
const hookList = [
'applypatch-msg',
'pre-applypatch',
'post-applypatch',
'pre-commit',
'pre-merge-commit',
'prepare-commit-msg',
'commit-msg',
'post-commit',
'pre-rebase',
'post-checkout',
'post-merge',
'pre-push',
'post-update',
'push-to-checkout',
'pre-auto-gc',
'post-rewrite',
'sendemail-validate',
];
function getHooks(gitHooksDir) {
return hookList.map((hookName) => path.join(gitHooksDir, hookName));
}
function writeHook(filename, script) {
fs.writeFileSync(filename, script, 'utf-8');
fs.chmodSync(filename, 0o0755);
}
function createHook(filename) {
const name = path.basename(filename);
const hookScript = getHookScript();
// Check if hook exist
if (fs.existsSync(filename)) {
const hook = fs.readFileSync(filename, 'utf-8');
// Migrate
if (is_1.isGhooks(hook)) {
console.log(`migrating existing ghooks script: ${name}`);
return writeHook(filename, hookScript);
}
// Migrate
if (is_1.isPreCommit(hook)) {
console.log(`migrating existing pre-commit script: ${name}`);
return writeHook(filename, hookScript);
}
// Update
if (is_1.isHusky(hook) || is_1.isYorkie(hook)) {
return writeHook(filename, hookScript);
}
// Skip
console.log(`skipping existing user hook: ${name}`);
return;
}
// Create hook if it doesn't exist
writeHook(filename, hookScript);
}
function createHooks(gitHooksDir) {
getHooks(gitHooksDir).forEach(createHook);
}
exports.createHooks = createHooks;
function canRemove(filename) {
if (fs.existsSync(filename)) {
const data = fs.readFileSync(filename, 'utf-8');
return is_1.isHusky(data);
}
return false;
}
function removeHook(filename) {
fs.unlinkSync(filename);
}
function removeHooks(gitHooksDir) {
getHooks(gitHooksDir).filter(canRemove).forEach(removeHook);
}
exports.removeHooks = removeHooks;

56
node_modules/husky/lib/installer/index.js generated vendored Normal file
View File

@ -0,0 +1,56 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const debug_1 = require("../debug");
const getConf_1 = require("../getConf");
const hooks_1 = require("./hooks");
const localScript_1 = require("./localScript");
const mainScript_1 = require("./mainScript");
// This prevents the case where someone would want to debug a node_module that has
// husky as devDependency and run npm install from node_modules directory
function isInNodeModules(dir) {
return dir.indexOf('node_modules') !== -1;
}
function getGitHooksDir(gitDir) {
return path_1.default.join(gitDir, 'hooks');
}
function install({ absoluteGitCommonDir, relativeUserPkgDir, userPkgDir, pmName, // package manager name
isCI, }) {
// Get conf from package.json or .huskyrc
const conf = getConf_1.getConf(userPkgDir);
// Checks
if (isCI && conf.skipCI) {
console.log('CI detected, skipping Git hooks installation.');
return;
}
if (isInNodeModules(userPkgDir)) {
console.log('Trying to install from node_modules directory, skipping Git hooks installation.');
return;
}
// Create hooks directory if it doesn't exist
const gitHooksDir = getGitHooksDir(absoluteGitCommonDir);
if (!fs_1.default.existsSync(gitHooksDir)) {
fs_1.default.mkdirSync(gitHooksDir);
}
debug_1.debug(`Installing hooks in ${gitHooksDir}`);
hooks_1.createHooks(gitHooksDir);
localScript_1.createLocalScript(gitHooksDir, pmName, relativeUserPkgDir);
mainScript_1.createMainScript(gitHooksDir);
}
exports.install = install;
function uninstall({ absoluteGitCommonDir, userPkgDir, }) {
if (isInNodeModules(userPkgDir)) {
console.log('Trying to uninstall from node_modules directory, skipping Git hooks uninstallation.');
return;
}
// Remove hooks
const gitHooksDir = getGitHooksDir(absoluteGitCommonDir);
hooks_1.removeHooks(gitHooksDir);
localScript_1.removeLocalScript(gitHooksDir);
mainScript_1.removeMainScript(gitHooksDir);
}
exports.uninstall = uninstall;

24
node_modules/husky/lib/installer/is.js generated vendored Normal file
View File

@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const hooks_1 = require("./hooks");
function isHusky(data) {
// Husky v0.14 and prior used #husky as an identifier.
// Just in case some previous hooks weren't correctly uninstalled,
// and for a better transition this will allow v0.15+ to uninstall them as well.
const previousHuskyIdentifier = '#husky';
return (data.indexOf(hooks_1.huskyIdentifier) !== -1 ||
data.indexOf(previousHuskyIdentifier) !== -1);
}
exports.isHusky = isHusky;
function isYorkie(data) {
return data.indexOf('#yorkie') !== -1;
}
exports.isYorkie = isYorkie;
function isGhooks(data) {
return data.indexOf('// Generated by ghooks. Do not edit this file.') !== -1;
}
exports.isGhooks = isGhooks;
function isPreCommit(data) {
return data.indexOf('./node_modules/pre-commit/hook') !== -1;
}
exports.isPreCommit = isPreCommit;

24
node_modules/husky/lib/installer/localScript.js generated vendored Normal file
View File

@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const path = require("path");
const getBanner_1 = require("./getBanner");
function getLocalScript(pmName, relativeUserPkgDir) {
return `${getBanner_1.getBanner()}
packageManager=${pmName}
cd "${relativeUserPkgDir}"
`;
}
exports.getLocalScript = getLocalScript;
function createLocalScript(gitHooksDir, pmName, relativeUserPkgDir) {
fs.writeFileSync(path.join(gitHooksDir, 'husky.local.sh'), getLocalScript(pmName, relativeUserPkgDir), 'utf-8');
}
exports.createLocalScript = createLocalScript;
function removeLocalScript(gitHooksDir) {
const filename = path.join(gitHooksDir, 'husky.local.sh');
if (fs.existsSync(filename)) {
fs.unlinkSync(filename);
}
}
exports.removeLocalScript = removeLocalScript;

25
node_modules/husky/lib/installer/mainScript.js generated vendored Normal file
View File

@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const path = require("path");
const getBanner_1 = require("./getBanner");
const read_pkg_1 = require("../read-pkg");
function getMainScript() {
const pkg = read_pkg_1.readPkg(path.join(__dirname, '../..'));
const mainScript = fs
.readFileSync(path.join(__dirname, '../../sh/husky.sh'), 'utf-8')
.replace('huskyVersion="0.0.0"', `huskyVersion="${pkg.version}"`);
return [getBanner_1.getBanner(), '', mainScript].join('\n');
}
exports.getMainScript = getMainScript;
function createMainScript(gitHooksDir) {
fs.writeFileSync(path.join(gitHooksDir, 'husky.sh'), getMainScript(), 'utf-8');
}
exports.createMainScript = createMainScript;
function removeMainScript(gitHooksDir) {
const filename = path.join(gitHooksDir, 'husky.sh');
if (fs.existsSync(filename)) {
fs.unlinkSync(filename);
}
}
exports.removeMainScript = removeMainScript;

13
node_modules/husky/lib/read-pkg.js generated vendored Normal file
View File

@ -0,0 +1,13 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
function readPkg(dir) {
const pkgFile = path_1.default.resolve(dir, 'package.json');
const pkgStr = fs_1.default.readFileSync(pkgFile, 'utf-8');
return JSON.parse(pkgStr);
}
exports.readPkg = readPkg;

19
node_modules/husky/lib/runner/bin.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const checkGitDirEnv_1 = require("../checkGitDirEnv");
const _1 = __importDefault(require("./"));
async function run() {
checkGitDirEnv_1.checkGitDirEnv();
try {
const status = await _1.default(process.argv);
process.exit(status);
}
catch (err) {
console.log('Husky > unexpected error', err);
process.exit(1);
}
}
run();

87
node_modules/husky/lib/runner/index.js generated vendored Normal file
View File

@ -0,0 +1,87 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = __importDefault(require("chalk"));
const child_process_1 = require("child_process");
const getConf_1 = require("../getConf");
const read_pkg_1 = require("../read-pkg");
// Husky <1.0.0 (commands were defined in pkg.scripts)
function getOldCommand(cwd, hookName) {
// In some cases, package.json may not exist
// For example, when switching to gh-page branch
let pkg = {};
try {
pkg = read_pkg_1.readPkg(cwd);
}
catch (err) {
if (err.code !== 'ENOENT') {
throw err;
}
}
return pkg && pkg.scripts && pkg.scripts[hookName.replace('-', '')];
}
// Husky >= 1.0.0
function getCommand(cwd, hookName) {
const config = getConf_1.getConf(cwd);
return config && config.hooks && config.hooks[hookName];
}
function runCommand(cwd, hookName, cmd, env) {
console.log(`husky > ${hookName} (node ${process.version})`);
const { status } = child_process_1.spawnSync('sh', ['-c', cmd], {
cwd,
env: Object.assign(Object.assign({}, process.env), env),
stdio: 'inherit',
});
if (status !== 0) {
const noVerifyMessage = [
'commit-msg',
'pre-commit',
'pre-rebase',
'pre-push',
].includes(hookName)
? '(add --no-verify to bypass)'
: '(cannot be bypassed with --no-verify due to Git specs)';
console.log(`husky > ${hookName} hook failed ${noVerifyMessage}`);
}
// If shell exits with 127 it means that some command was not found.
// However, if husky has been deleted from node_modules, it'll be a 127 too.
// To be able to distinguish between both cases, 127 is changed to 1.
if (status === 127) {
return 1;
}
return status || 0;
}
/**
* @param {array} argv process.argv
* @param {string} options.cwd cwd
* @param {promise} options.getStdinFn - used for mocking only
*/
async function run([, , hookName = '', ...HUSKY_GIT_PARAMS], { cwd = process.cwd() } = {}) {
const oldCommand = getOldCommand(cwd, hookName);
const command = getCommand(cwd, hookName);
// Add HUSKY_GIT_PARAMS to env
const env = {};
if (HUSKY_GIT_PARAMS === null || HUSKY_GIT_PARAMS === void 0 ? void 0 : HUSKY_GIT_PARAMS.length) {
env.HUSKY_GIT_PARAMS = HUSKY_GIT_PARAMS.join(' ');
}
if (command) {
return runCommand(cwd, hookName, command, env);
}
if (oldCommand) {
console.log(chalk_1.default.red(`
Warning: Setting ${hookName} script in package.json > scripts will be deprecated.
Please move it to husky.hooks in package.json or .huskyrc file.
For an automatic update you can also run:
npx --no-install husky-upgrade
yarn husky-upgrade
See https://github.com/typicode/husky for more information.
`));
return runCommand(cwd, hookName, oldCommand, env);
}
return 0;
}
exports.default = run;

8
node_modules/husky/lib/upgrader/bin.js generated vendored Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env node
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = __importDefault(require("./index"));
index_1.default(process.cwd());

65
node_modules/husky/lib/upgrader/index.js generated vendored Normal file
View File

@ -0,0 +1,65 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const read_pkg_1 = require("../read-pkg");
const hookList = {
applypatchmsg: 'applypatch-msg',
commitmsg: 'commit-msg',
postapplypatch: 'post-applypatch',
postcheckout: 'post-checkout',
postcommit: 'post-commit',
postmerge: 'post-merge',
postreceive: 'post-receive',
postrewrite: 'post-rewrite',
postupdate: 'post-update',
preapplypatch: 'pre-applypatch',
preautogc: 'pre-auto-gc',
precommit: 'pre-commit',
premergecommit: 'pre-merge-commit',
preparecommitmsg: 'prepare-commit-msg',
prepush: 'pre-push',
prerebase: 'pre-rebase',
prereceive: 'pre-receive',
pushtocheckout: 'push-to-checkout',
sendemailvalidate: 'sendemail-validate',
update: 'update',
};
function upgrade(cwd) {
const pkgFile = path_1.default.join(cwd, 'package.json');
if (fs_1.default.existsSync(pkgFile)) {
const pkg = read_pkg_1.readPkg(cwd);
console.log(`husky > upgrading ${pkgFile}`);
// Don't overwrite 'husky' field if it exists
if (pkg.husky) {
return console.log(`husky field in package.json isn't empty, skipping automatic upgrade`);
}
const hooks = {};
// Find hooks in package.json 'scripts' field
Object.keys(hookList).forEach((name) => {
if (pkg.scripts) {
const script = pkg.scripts[name];
if (script) {
delete pkg.scripts[name];
const newName = hookList[name];
hooks[newName] = script.replace(/\bGIT_PARAMS\b/g, 'HUSKY_GIT_PARAMS');
console.log(`moved scripts.${name} to husky.hooks.${newName}`);
}
}
});
// Move found hooks to 'husky.hooks' field
if (Object.keys(hooks).length) {
pkg.husky = { hooks };
}
else {
console.log('no hooks found');
}
// Update package.json
fs_1.default.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`, 'utf-8');
console.log(`husky > done`);
}
}
exports.default = upgrade;

115
node_modules/husky/package.json generated vendored Normal file
View File

@ -0,0 +1,115 @@
{
"name": "husky",
"version": "4.3.8",
"description": "Prevents bad commit or push (git hooks, pre-commit/precommit, pre-push/prepush, post-merge/postmerge and all that stuff...)",
"bin": {
"husky-run": "./bin/run.js",
"husky-upgrade": "./lib/upgrader/bin.js"
},
"engines": {
"node": ">=10"
},
"scripts": {
"test": "npm run lint && jest",
"install": "node husky install",
"preuninstall": "node husky uninstall",
"build": "del-cli lib && tsc",
"version": "jest -u && git add -A src/installer/__tests__/__snapshots__",
"postversion": "git push && git push --tags",
"prepublishOnly": "npm run test && npm run build && pinst --enable && pkg-ok",
"postpublish": "pinst --disable",
"lint": "eslint . --ext .js,.ts --ignore-path .gitignore",
"fix": "npm run lint -- --fix",
"doc": "markdown-toc -i README.md",
"postinstall": "opencollective-postinstall || exit 0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/typicode/husky.git"
},
"keywords": [
"git",
"hook",
"hooks",
"pre-commit",
"precommit",
"post-commit",
"postcommit",
"pre-push",
"prepush",
"post-merge",
"postmerge",
"test",
"lint"
],
"author": "Typicode <typicode@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/typicode/husky/issues"
},
"homepage": "https://github.com/typicode/husky#readme",
"dependencies": {
"chalk": "^4.0.0",
"ci-info": "^2.0.0",
"compare-versions": "^3.6.0",
"cosmiconfig": "^7.0.0",
"find-versions": "^4.0.0",
"opencollective-postinstall": "^2.0.2",
"pkg-dir": "^5.0.0",
"please-upgrade-node": "^3.2.0",
"slash": "^3.0.0",
"which-pm-runs": "^1.0.0"
},
"devDependencies": {
"@types/ci-info": "^2.0.0",
"@types/cosmiconfig": "^6.0.0",
"@types/is-ci": "^2.0.0",
"@types/jest": "^25.2.1",
"@types/mkdirp": "^1.0.0",
"@types/node": "^13.11.1",
"@typescript-eslint/eslint-plugin": "^2.27.0",
"@typescript-eslint/parser": "^2.27.0",
"cross-env": "^7.0.2",
"del": "^5.1.0",
"del-cli": "^3.0.1",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.1",
"eslint-config-xo-space": "^0.24.0",
"eslint-plugin-prettier": "^3.1.2",
"formatree": "^1.0.2",
"jest": "^25.3.0",
"markdown-toc": "^1.2.0",
"mkdirp": "^1.0.4",
"pinst": "^2.1.1",
"pkg-ok": "^2.3.1",
"prettier": "^2.0.4",
"tempy": "^0.5.0",
"ts-jest": "^25.3.1",
"type-fest": "^0.13.1",
"typescript": "^3.8.3"
},
"jest": {
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"testPathIgnorePatterns": [
"node_modules",
"__env__.ts"
],
"moduleFileExtensions": [
"ts",
"js",
"json",
"node"
]
},
"collective": {
"type": "opencollective",
"url": "https://opencollective.com/husky"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/husky"
}
}

90
node_modules/husky/sh/husky.sh generated vendored Normal file
View File

@ -0,0 +1,90 @@
debug () {
if [ "$HUSKY_DEBUG" = "true" ] || [ "$HUSKY_DEBUG" = "1" ]; then
echo "husky:debug $1"
fi
}
command_exists () {
command -v "$1" >/dev/null 2>&1
}
run_command () {
if command_exists "$1"; then
"$@" husky-run $hookName $gitParams
exitCode="$?"
debug "$* husky-run exited with $exitCode exit code"
if [ $exitCode -eq 127 ]; then
echo "Can't find Husky, skipping $hookName hook"
echo "You can reinstall it using 'npm install husky --save-dev' or delete this hook"
else
exit $exitCode
fi
else
echo "Can't find $1 in PATH: $PATH"
echo "Skipping $hookName hook"
exit 0
fi
}
hookIsDefined () {
grep -qs $hookName \
package.json \
.huskyrc \
.huskyrc.json \
.huskyrc.yaml \
.huskyrc.yml
}
huskyVersion="0.0.0"
gitParams="$*"
hookName="$(basename "$0")"
debug "husky v$huskyVersion - $hookName"
# Skip if HUSKY_SKIP_HOOKS is set
if [ "$HUSKY_SKIP_HOOKS" = "true" ] || [ "$HUSKY_SKIP_HOOKS" = "1" ]; then
debug "HUSKY_SKIP_HOOKS is set to $HUSKY_SKIP_HOOKS, skipping hook"
exit 0
fi
# Source user var and change directory
. "$(dirname "$0")/husky.local.sh"
debug "Current working directory is $(pwd)"
# Skip fast if hookName is not defined
# Don't skip if .huskyrc.js or .huskyrc.config.js are used as the heuristic could
# fail due to the dynamic aspect of JS. For example:
# `"pre-" + "commit"` or `require('./config/hooks')`)
if [ ! -f .huskyrc.js ] && [ ! -f huskyrc.cjs ] && [ ! -f husky.config.js ] && [ ! -f husky.config.cjs ] && ! hookIsDefined; then
debug "$hookName config not found, skipping hook"
exit 0
fi
# Source user ~/.huskyrc
if [ -f ~/.huskyrc ]; then
debug "source ~/.huskyrc"
. ~/.huskyrc
fi
# Set HUSKY_GIT_STDIN from stdin
case $hookName in
"pre-push"|"post-rewrite")
export HUSKY_GIT_STDIN="$(cat)";;
esac
# Windows 10, Git Bash and Yarn 1 installer
if command_exists winpty && test -t 1; then
exec < /dev/tty
fi
# Run husky-run with the package manager used to install Husky
case $packageManager in
"npm") run_command npx --no-install;;
"npminstall") run_command npx --no-install;;
"pnpm") run_command pnpx --no-install;;
"yarn") run_command yarn run --silent;;
*) echo "Unknown package manager: $packageManager"; exit 0;;
esac