0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

husky(v8当時)セットアップ手順

Posted at

バージョンによって、設定方法が異なるようだったのでメモを残しておきます。

以下公式なので、最新情報は以下参照してください。

install

yarn add husky --dev

npmの場合はnpm install husky --save-devです。

setup

以下参考に、該当するコマンドをうってください。

npx husky-init && npm install       # npm
npx husky-init && yarn              # Yarn 1
yarn dlx husky-init --yarn2 && yarn # Yarn 2+
pnpm dlx husky-init && pnpm install # pnpm

これで、いろいろ動いて.husky/pre-commitが作成されているはずです。

.husky/pre-commit
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm test

edit

npm testの部分をpre-commit時に実行したいスクリプトに修正してコミットします。
自分はyarn lintというコマンドを実行したかったので以下のように書き換えてコミットしました。

.husky/pre-commit
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?