Skip to content

Commit

Permalink
feat: --no-restage flag for skipping re-stage step in staged mode (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
benwiley4000 committed Sep 18, 2018
1 parent ea58162 commit 663e5a7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -76,6 +76,10 @@ Pre-commit mode. Under this flag only staged files will be formatted, and they w

Partially staged files will not be re-staged after formatting and pretty-quick will exit with a non-zero exit code. The intent is to abort the git commit and allow the user to amend their selective staging to include formatting fixes.

### `--no-restage` (only git)

Use with the `--staged` flag to skip re-staging files after formatting.

### `--branch`

When not in `staged` pre-commit mode, use this flag to compare changes with the specified branch. Defaults to `master` (git) / `default` (hg) branch.
Expand Down
2 changes: 1 addition & 1 deletion bin/pretty-quick.js
Expand Up @@ -7,7 +7,7 @@ const mri = require('mri');

const prettyQuick = require('..').default;

const args = mri(process.argv.slice(2));
const args = mri(process.argv.slice(2), { default: { restage: true } });

let success = true;
prettyQuick(
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Expand Up @@ -9,6 +9,7 @@ export default (
config,
since,
staged,
restage,
branch,
onFoundSinceRevision,
onFoundChangedFiles,
Expand Down Expand Up @@ -46,7 +47,7 @@ export default (
config,
onWriteFile: file => {
onWriteFile && onWriteFile(file);
if (staged) {
if (staged && restage) {
if (wasFullyStaged(file)) {
scm.stageFile(directory, file);
} else {
Expand Down

0 comments on commit 663e5a7

Please sign in to comment.