Builds the command.
(argv: Argv)
| 20 | |
| 21 | /** Builds the command. */ |
| 22 | function builder(argv: Argv) { |
| 23 | return argv |
| 24 | .option('file', { |
| 25 | type: 'string', |
| 26 | conflicts: ['file-env-variable'], |
| 27 | description: 'The path of the commit message file.', |
| 28 | }) |
| 29 | .option('file-env-variable' as 'fileEnvVariable', { |
| 30 | type: 'string', |
| 31 | conflicts: ['file'], |
| 32 | description: 'The key of the environment variable for the path of the commit message file.', |
| 33 | coerce: (arg: string | undefined) => { |
| 34 | if (arg === undefined) { |
| 35 | return arg; |
| 36 | } |
| 37 | const file = process.env[arg]; |
| 38 | if (!file) { |
| 39 | throw new Error(`Provided environment variable "${arg}" was not found.`); |
| 40 | } |
| 41 | return file; |
| 42 | }, |
| 43 | }) |
| 44 | .option('error', { |
| 45 | type: 'boolean', |
| 46 | description: |
| 47 | 'Whether invalid commit messages should be treated as failures rather than a warning', |
| 48 | default: null, |
| 49 | defaultDescription: '`True` on CI or can be enabled through ng-dev user-config.', |
| 50 | }); |
| 51 | } |
| 52 | |
| 53 | /** Handles the command. */ |
| 54 | async function handler({error, file, fileEnvVariable}: Arguments<ValidateFileOptions>) { |
nothing calls this directly
no outgoing calls
no test coverage detected