@easyops/git-exec-and-restage

Safely amend Git commits after applying auto-fixing tools

Stats

StarsIssuesVersionUpdatedCreatedSize
@easyops/git-exec-and-restage
301.0.44 years ago4 years agoMinified + gzip package size for @easyops/git-exec-and-restage in KB

Readme

git-exec-and-restage

npm Build Status

Safely amend Git commits after applying auto-fixing tools

git-exec-and-restage executes a command for you on a set of files. This command may modify the files (imagine a linter in auto-fix mode, like prettier --write or eslint --fix). If the files were fully staged before the command ran, the changes will be automatically added to the Git index; if they were partially changed the Git index will remain untouched.

Table of Contents

Install

yarn add --dev @easyops/git-exec-and-restage

Usage

Manually e.g. with prettier:

git-exec-and-restage prettier --write -- file1.js file2.js

Automatically e.g. with lint-staged:

package.json

{
  "scripts": {
    "precommit": "lint-staged"
  },
  "lint-staged": {
    "*.js": ["git-exec-and-restage eslint --fix --"]
  }
}

Contribute

PRs welcome.

Acknowledgements

This package owes a great deal to Matthew Chase Whittemore's staged-git-files.

License

MIT © Moti Zilberman

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.