@funish/githooks
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

@funish/githooks

npm version npm downloads npm license Contributor Covenant

Programmatically create git hooks, powered by Funish.

Inspired by husky and with an extremely similar implementation, but modified and supplemented with some possible details.

Getting started

# npm
$ npm install -D @funish/githooks

# yarn
$ yarn add -D @funish/githooks

# pnpm
$ pnpm add -D @funish/githooks

Usage

Recommend

For unified processes, we prefer to use configuration files to manage certain simple commands. This method is only suitable for fixed configuration management and githooks install should be re-run after making changes to the configuration file.

// githooks.config.ts
import { defineGithooksConfig } from "@funish/githooks";

export default defineGithooksConfig({
  hooks: {
    "pre-commit": "pnpm lint staged",
    "commit-msg": "pnpm lint commit-msg",
  },
});

Configuration

Type definition

export interface GithooksConfig {
  path?: string;
  hooks?: {
    [key in GithooksName]?: string;
  };
  gitConfig?: object;
  extends?: string | [string];
}

Husky Like

We can also use it in a similar way to Husky, except that the default folder will be .githooks.

# Install Git hooks during the post-installation phase of the lifecycle.
# Or you can use `pnpm githooks install -S prepare`.
$ pnpm githooks install -S

# Set up Git hooks.
$ pnpm githooks setup <hooks> [script]

# Uninstall Git hooks.
$ pnpm githooks uninstall

# Migrating from husky to @funish/githooks.
$ pnpm githooks migrate

CLI

$ githooks -h

USAGE githooks install|setup|uninstall|migrate

COMMANDS

    install    Install Git hooks.
      setup    Set up Git hooks.
  uninstall    Uninstall Git hooks.
    migrate    Migrating from husky to @funish/githooks.

Use githooks <command> --help for more information about a command.

Interfaces

See it on JSDoc.

Related Efforts

License

Readme

Keywords

Package Sidebar

Install

npm i @funish/githooks

Weekly Downloads

111

Version

0.0.5

License

MIT

Unpacked Size

18.9 kB

Total Files

13

Last publish

Collaborators

  • demomacro