https://github.com/imcuttle/ci-run-staged
Run command inferred by git staged file expediently in ci.
https://github.com/imcuttle/ci-run-staged
ci-run commit git range staged-files
Last synced: about 2 months ago
JSON representation
Run command inferred by git staged file expediently in ci.
- Host: GitHub
- URL: https://github.com/imcuttle/ci-run-staged
- Owner: imcuttle
- License: mit
- Created: 2018-05-19T09:31:17.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-04-30T01:15:09.000Z (about 4 years ago)
- Last Synced: 2025-03-23T02:33:59.182Z (over 1 year ago)
- Topics: ci-run, commit, git, range, staged-files
- Language: JavaScript
- Homepage:
- Size: 101 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: License
Awesome Lists containing this project
README
# ci-run-staged
[](https://travis-ci.org/imcuttle/ci-run-staged)
[](https://codecov.io/github/imcuttle/ci-run-staged?branch=master)
[](https://www.npmjs.com/package/ci-run-staged)
[](https://www.npmjs.com/package/ci-run-staged)
Run command inferred by git staged file expediently in ci.
Be inspired by [lint-staged](https://github.com/okonet/lint-staged)
## Installation and setup
1. `npm install --save-dev ci-run-staged`
2. Update your package.json like this:
```diff
{
"scripts": {
+ "ci-run-staged": "ci-run-staged"
},
+ "ci-run-staged": {
+ "added": {
+ "doc/**/*.md": [
+ "send email..."
+ ]
+ },
+ "all": {
+ "*": "cmd"
+ }
+ "deleted|Modified": {
+ "*": "cmd"
+ }
+ }
}
```
3. 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*`.
```bash
DEBUG=ci-run-staged* ./node_modules/.bin/ci-run-staged
```
## FAQ
#### How to include dot files
```json
{
"ci-run-staged": {
"all": {
"{.,}*": "echo"
}
}
}
```