Giter VIP home page Giter VIP logo

pre-push's Introduction

pre-push

A simple pre-push hook installer for git. This will ensure that your test suite passes before you can push your changes. In addition to running your npm test it also has the option to run custom scripts that you have specified in your package.json.

Installation

It's advised to install this module as devDependency in your package.json file so it doesn't get installed on production servers. Run:

npm install --save-dev pre-push

To install it as devDependency. When this module is installed it will override the existing pre-push file in your .git/hooks folder. Existing pre-push hooks will be backed up.

Configuration

pre-push will try to run your npm test command by default. It does this by running npm run test in the root of your git repository. It will only run that command if it's not the default values that are entered when you issue an npm init.

But pre-push is not limited to just running your npm test's during the push hook. It's also capable of running every other script that you've specified in your package.json "scripts" field. The only thing you need to do is add a pre-push array to your package.json that specifies which scripts you want to have ran and in which order:

{
  "name": "437464d0899504fb6b7b",
  "version": "0.0.0",
  "description": "ERROR: No README.md file found!",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "foo": "echo \"fooo\" && exit 0",
    "bar": "echo \"bar\" && exit 0"
  },
  "repository": {
    "type": "git",
    "url": "https://gist.github.com/437464d0899504fb6b7b.git"
  },
  "pre-push": [
    "foo",
    "bar",
    "test"
  ],
  "author": "",
  "license": "BSD",
  "gitHead": "6637d0771c3a89c4a60be087859dee5130f7a104"
}

In the example above, it will first run: npm run foo then npm run bar and finally npm run test which will make the push fail as it returns the error code 1.

To learn more about the scripts, please read the official npm documentation:

https://npmjs.org/doc/scripts.html

License

MIT

pre-push's People

Contributors

3rd-eden avatar jgantunes avatar raynos avatar tomfuertes avatar alexdisler avatar alexindigo avatar bregenspan avatar jenkins-li-bot avatar seriousmanual avatar

Watchers

James Cloos avatar  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.