prepush-if-changed
A tool that runs your commands if any git-pushed files match the glob written to be used as a pre-push hook
Last updated 5 months ago by dprovodnikov .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install prepush-if-changed 
SYNC missed versions from official npm registry.

prepush-if-changed Build Status Coverage Status

Acts as a pre-push hook to run commands only if committed files match the specified glob.

Installation

Using npm

npm install --save-dev prepush-if-changed

Using yarn

yarn add -D prepush-if-changed

Why

It doesn't always make sense to run pre-push hooks on every push. Sometimes you need to trigger a hook only when the pushed changes affect a specific area of your file structure. This project contains a script that will check committed files against a glob and only trigger the task if there's a match.

The script will compare your current local branch with the remote(origin) one. If the remote branch does not exist the script will exit with code 0 without performing any execution.

Configuration

You are going to need a git hook management library. We'll use husky for this example.

A configuration like this will execute unit tests once you attempt to push changes of any js/jsx files inside the src folder

This example uses package.json for configuration.

// package.json
{
  "husky": {
    "hooks": {
      "pre-push": "prepush-if-changed"
    }
  },
  "prepush-if-changed": {
    "src/**/*.js?(x)": "npm run test"
  }
}

You can use the following files to write a config:

package.json,
.prepushrc,
.prepushrc.json,
.prepushrc.yaml,
.prepushrc.yml,
.prepushrc.js,
prepush.config.js,

Matching files

Your commands will be executed only if any of the committed files match the glob. prepush-if-changed uses micromatch for matching files.

Current Tags

  • 1.0.8                                ...           latest (5 months ago)

9 Versions

  • 1.0.8                                ...           5 months ago
  • 1.0.7                                ...           5 months ago
  • 1.0.6                                ...           5 months ago
  • 1.0.5                                ...           5 months ago
  • 1.0.4                                ...           5 months ago
  • 1.0.3                                ...           5 months ago
  • 1.0.2                                ...           5 months ago
  • 1.0.1                                ...           5 months ago
  • 1.0.0                                ...           5 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 9
Dependencies (7)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |