Run command inferred by git staged file expediently in ci.
Be inspired by lint-staged
npm install --save-dev ci-run-staged
- 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"
+ }
+ }
}
- Execute
npm run ci-run-staged
in your ci scripts.
SGF-Status (git status code)
- Added
- Copied
- Deleted
- Modified
- Renamed
- Type-Change [i.e. regular file, symlink, submodule, etc.]
- Unmerged
- Unknown
./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
Can be enabled by setting the environment variable DEBUG
to ci-run-staged*
.
DEBUG=ci-run-staged* ./node_modules/.bin/ci-run-staged
{
"ci-run-staged": {
"all": {
"{.,}*": "echo"
}
}
}