From e658ebc157c15bc0138315e56a0cbe8ef213c8d5 Mon Sep 17 00:00:00 2001 From: Ben Wiley Date: Mon, 17 Sep 2018 13:34:39 -0400 Subject: [PATCH] feat: --no-stage flag for skipping re-stage step in staged mode (#39) --- README.md | 4 ++++ bin/pretty-quick.js | 2 +- src/index.js | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 66332e9..93101af 100644 --- a/README.md +++ b/README.md @@ -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-stage` (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. diff --git a/bin/pretty-quick.js b/bin/pretty-quick.js index b5885d5..5c5eed1 100755 --- a/bin/pretty-quick.js +++ b/bin/pretty-quick.js @@ -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( diff --git a/src/index.js b/src/index.js index 5076ca0..d1c0d86 100644 --- a/src/index.js +++ b/src/index.js @@ -9,6 +9,7 @@ export default ( config, since, staged, + restage, branch, onFoundSinceRevision, onFoundChangedFiles, @@ -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 {