imcuttle / ci-run-staged

Run command inferred by git staged file expediently in ci.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ci-run-staged

build status Test coverage NPM version NPM Downloads

Run command inferred by git staged file expediently in ci.

Be inspired by lint-staged

Installation and setup

  1. npm install --save-dev ci-run-staged
  2. Update your package.json like this:
{
  "scripts": {
+   "ci-run-staged": "ci-run-staged"
  },
+ "ci-run-staged": {
+   "added": {
+     "doc/**/*.md": [
+       "send email..."
+     ]
+   },
+   "all": {
+     "*": "cmd"
+   }
+   "deleted|Modified": {
+     "*": "cmd"
+   }
+ }
}
  1. Execute npm run ci-run-staged in your ci scripts.

Statuses

SGF-Status (git status code)

  • Added
  • Copied
  • Deleted
  • Modified
  • Renamed
  • Type-Change [i.e. regular file, symlink, submodule, etc.]
  • Unmerged
  • Unknown

Command line

./node_modules/.bin/ci-run-staged commit-range # like HEAD, hashA...hashB

When do not set commit range definitely, ci-run-staged would find range like this:

process.env.COMMIT_RANGE || process.env.TRAVIS_COMMIT_RANGE || process.env.CIRCLE_COMPARE_URL

Debugger

Can be enabled by setting the environment variable DEBUG to ci-run-staged*.

DEBUG=ci-run-staged* ./node_modules/.bin/ci-run-staged

FAQ

How to include dot files

{
  "ci-run-staged": {
    "all": {
      "{.,}*": "echo"
    }
  }
}

About

Run command inferred by git staged file expediently in ci.

License:MIT License


Languages

Language:JavaScript 100.0%