| 5 | import { goSync } from '@api3/promise-utils'; |
| 6 | |
| 7 | const hideSecrets = (command: string, options?: ExecSyncOptions) => { |
| 8 | // There are currently 2 secrets being logged: |
| 9 | // * DockerHub auth token - stdin |
| 10 | // * GitHub auth token - remote URL |
| 11 | // Third secret, the NPM auth token, is stored in a file therefore not logged |
| 12 | |
| 13 | // DockerHub auth token |
| 14 | const hiddenOptions = has(options, 'input') ? { ...options, input: '***' } : options; |
| 15 | |
| 16 | // GitHub auth token |
| 17 | const hiddenCommand = command.replace(/(https:\/\/x-access-token):(.*?)(@github\.com.*$)/, '$1:***$3'); |
| 18 | |
| 19 | return { hiddenCommand, hiddenOptions }; |
| 20 | }; |
| 21 | |
| 22 | export const runCommand = (command: string, options?: ExecSyncOptions) => { |
| 23 | const { hiddenCommand, hiddenOptions } = hideSecrets(command, options); |