()
| 26 | |
| 27 | // eslint-disable-next-line complexity |
| 28 | const main = async () => { |
| 29 | try { |
| 30 | const {cliAnswers, cliOptions, passThroughParams} = parseArgs(); |
| 31 | |
| 32 | let state = null; |
| 33 | |
| 34 | if (cliOptions.disableEmoji) { |
| 35 | state = createState({disableEmoji: cliOptions.disableEmoji}); |
| 36 | } else { |
| 37 | state = createState(); |
| 38 | } |
| 39 | |
| 40 | if (cliOptions.dryRun) { |
| 41 | // eslint-disable-next-line no-console |
| 42 | console.log('Running in dry mode.'); |
| 43 | } else if ( |
| 44 | !passThroughParams['allow-empty'] && |
| 45 | !passThroughParams.a && |
| 46 | !passThroughParams.amend |
| 47 | ) { |
| 48 | try { |
| 49 | /** |
| 50 | * @author https://github.com/rodrigograca31 |
| 51 | * @see https://github.com/streamich/git-cz/issues/177 |
| 52 | * |
| 53 | * Exits with 1 if there are differences and 0 if no differences. |
| 54 | */ |
| 55 | execSync('git diff HEAD --staged --quiet --exit-code'); |
| 56 | |
| 57 | // Executes the following line only if the one above didn't crash (exit code: 0) |
| 58 | signale.error('No files staged!'); |
| 59 | |
| 60 | // eslint-disable-next-line no-process-exit |
| 61 | process.exit(0); |
| 62 | } catch (error) { |
| 63 | // eslint-disable no-empty |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | if (cliOptions.nonInteractive) { |
| 68 | await runNonInteractiveMode(state, cliAnswers); |
| 69 | } else { |
| 70 | await runInteractiveQuestions(state, cliAnswers); |
| 71 | } |
| 72 | |
| 73 | const message = formatCommitMessage(state); |
| 74 | |
| 75 | const appendedArgs = []; |
| 76 | |
| 77 | // eslint-disable-next-line guard-for-in |
| 78 | for (const key in passThroughParams) { |
| 79 | const value = passThroughParams[key]; |
| 80 | |
| 81 | if (key.length === 1) { |
| 82 | appendedArgs.push('-' + key); |
| 83 | } else { |
| 84 | appendedArgs.push('--' + key); |
| 85 | } |
no test coverage detected
searching dependent graphs…