Code Monkey home page Code Monkey logo

git-scripts's Introduction

git-scripts NPM Version

NPM

Manage git hooks with the "git.scripts" field of the package.json like npm-scripts.

{
  "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 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.

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

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 [email protected]

Maintainer

Huan LI (李卓桓) [email protected]

License

MIT

git-scripts's People

Contributors

binsee avatar charcute avatar huan avatar marcoslhc avatar markablov avatar nkzawa avatar stelcheck avatar tomneyland avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.