# git-scripts

> Git hooks integration for Node.js projects

Latest version **0.6.4** (published 2022-04-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install git-scripts
pnpm add git-scripts
yarn add git-scripts
bun add git-scripts
```

Provides the command `git-scripts`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.4 |
| Published | 2022-04-14 |
| First published | 2013-09-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 25.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 47 |
| Author | Naoyuki Kanezawa |
| Maintainers | nkzawa, zixia |
| Keywords | git, hooks, npm, scripts |

## Links

- npm: https://www.npmjs.com/package/git-scripts
- Repository: https://github.com/nkzawa/git-scripts
- Homepage: https://github.com/nkzawa/git-scripts#readme
- Issues: https://github.com/nkzawa/git-scripts/issues
- npm.io page: https://npm.io/package/git-scripts

## Dependencies (1)

- [commander](https://npm.io/package/commander.md) 2.6.0

## Recent versions

- 0.6.4 (latest) — 2022-04-14
- 0.5.3 (next) — 2022-04-07
- 0.6.2 — 2022-04-12
- 0.6.0 — 2022-04-08
- 0.4.3 — 2020-03-20
- 0.4.2 — 2020-03-20
- 0.3.3 — 2020-03-20
- 0.3.2 — 2020-03-20
- 0.3.0 — 2020-03-19
- 0.2.1 — 2015-02-08
- 0.2.0 — 2014-12-06
- 0.1.2 — 2013-12-20
- 0.1.1 — 2013-09-09
- 0.1.0 — 2013-09-07
- 0.0.0 — 2013-09-01

## README

# git-scripts [![NPM Version](https://badge.fury.io/js/git-scripts.svg)](https://www.npmjs.com/package/git-scripts)

![NPM](https://github.com/zixia/git-scripts/workflows/NPM/badge.svg)

Manage [git hooks](http://git-scm.com/book/en/Customizing-Git-Git-Hooks) with the "git.scripts" field of the package.json like [npm-scripts](https://npmjs.org/doc/scripts.html).

```json
{
  "name": "your-project",
  "version": "0.0.0",
  "description": "",
  "devDependencies": {
    "git-scripts": "*"
  },
  "git": {
    "scripts": {
      "pre-commit": "npm test",
      "post-merge": "npm install"
    }
  }
}
```

See also [this module's package.json](https://github.com/nkzawa/git-scripts/blob/master/package.json) as an example.

## Installation
    $ npm install git-scripts

NOTE: `.git/hooks` of your project is replaced when installed. You can restore it by uninstalling the module.

## Description
git-scripts supports all hooks including the following:

* applypatch-msg
* pre-applypatch
* post-applypatch
* pre-commit
* prepare-commit-msg
* commit-msg
* post-commit
* pre-rebase
* post-checkout
* post-merge
* pre-receive
* update
* post-receive
* post-update
* pre-auto-gc
* post-rewrite
* pre-push

## CLI
    $ npm install -g git-scripts

```
Usage: git-scripts <command> [options]

  Options:

    -h, --help     output usage information
    -V, --version  output the version number

  Commands:

    install [path]           install git-scripts
    uninstall [path]         uninstall git-scripts
    run <name> [args ...]    run arbitrary scripts
```

NOTE: Usually, you don't need CLI. Hooks are enabled automatically when you install the module locally.

## Using Programmatically
If you would like to use git-scripts programmatically, you can do that.

```js
var scripts = require('git-scripts');
var project = scripts('somewhere/yourproject');

project.install(function(err) {
  if (err) throw err;
  console.log('git-scripts was installed.');

  project.run('pre-commit', function(err) {
    if (err) throw err;
    console.log('pre-commit script succeeded.');
  });
});
```

### Documentation
```js
var scripts = require('git-scripts');
var project = scripts('somewhere/yourproject');
```

#### scripts([path])
Create a git-scripts instance for `path`.

#### project.install([callback])
Install git-scripts.

#### project.uninstall([callback])
Uninstall git-scripts.

#### project.run(name, [args ...], [callback])
Run an arbitrary command of `name`.

## Author

Naoyuki Kanezawa <naoyuki.kanezawa@gmail.com>

## Maintainer

[Huan LI](https://github.com/huan) ([李卓桓](http://linkedin.com/in/zixia)) <zixia@zixia.net>

## License

MIT

---
_Source: https://npm.io/package/git-scripts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
