Skip to content

Commit 33f9d5d

Browse files
committed
feat(main): add silent mode
1 parent fc81cce commit 33f9d5d

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ This is amazing feature.
9494
| `-D, --dry-run` | false | run dry-run mode |
9595
| `-i, --interactive` | false | run interactive mode |
9696
| `-s, --skip-options` | false | skip not required term input (interactive mode only) |
97+
| `-S, --silent` | false | dont show commit command |
9798
| `-V, --version` | | output the version number |
9899

99100
## Output usage information

git-consistent

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ const setOptions = (program, definitions, terms) => {
5050

5151
const createProgram = (program, definitions, terms) => {
5252
return setOptions(program, definitions, terms)
53-
.option(`-d, --duet`, 'run git-duet mode', false)
54-
.option(`-D, --dry-run`, 'run dry-run mode', false)
55-
.option(`-i, --interactive`, 'run interactive mode', false)
56-
.option(`-s, --skip-options`, 'skip not required term input (interactive mode only)', false)
53+
.option(`-d, --duet`, 'run git-duet mode')
54+
.option(`-D, --dry-run`, 'run dry-run mode')
55+
.option(`-i, --interactive`, 'run interactive mode')
56+
.option(`-s, --skip-options`, 'skip not required term input (interactive mode only)')
57+
.option(`-S, --silent`, "don't show commit command")
5758
.version(version)
5859
.parse(process.argv)
5960
}
@@ -196,26 +197,29 @@ const replaceTerm = (program, template, definition, term) => {
196197
return _.replace(template, `<${term}>`, decoratedValue)
197198
}
198199

199-
const gitCommit = (commitMessage, duet = false, dryRun = false) => {
200+
const gitCommit = (commitMessage, duet = false, silent = false, dryRun = false) => {
201+
let command
202+
if (duet) {
203+
command = `git duet-commit -m "${commitMessage}"`
204+
} else {
205+
command = `git commit -m "${commitMessage}"`
206+
}
207+
208+
if (!silent) console.log(`${infoColor}${command}${reset}`)
209+
200210
if (dryRun) {
201211
console.log("-------------------------")
202212
console.log(commitMessage)
203213
console.log("-------------------------")
204214
} else {
205-
let command
206-
if (duet) {
207-
command = `git duet-commit -m "${commitMessage}"`
208-
} else {
209-
command = `git commit -m "${commitMessage}"`
210-
}
211-
console.log(`${infoColor}${command}${reset}`)
212215
execSync(command)
213216
}
214217
}
215218

216219
const main = (program, template, definitions, terms) => {
217220
const commitMessage = replaceTerms(program, template, definitions, terms)
218-
gitCommit(commitMessage.trim(), program.duet, program.dryRun)
221+
222+
gitCommit(commitMessage.trim(), program.duet, program.silent, program.dryRun)
219223
}
220224

221225
//

0 commit comments

Comments
 (0)