(command: string, configPath: string, runConfigCmd: Function = runConfigCommand)
| 45 | * @param {Function} runConfigCmd runConfig method to be replaceable for unit testing |
| 46 | */ |
| 47 | export async function missingConfigurationPrompt(command: string, configPath: string, runConfigCmd: Function = runConfigCommand) { |
| 48 | const message = ( |
| 49 | `Could not execute "${command}" due to missing configuration, file ` + |
| 50 | `"${path.parse(configPath).name}[.js/.ts]" not found! ` + |
| 51 | 'Would you like to create one?' |
| 52 | ) |
| 53 | |
| 54 | const { config } = await inquirer.prompt({ |
| 55 | type: 'confirm', |
| 56 | name: 'config', |
| 57 | message, |
| 58 | default: false |
| 59 | }) |
| 60 | |
| 61 | /** |
| 62 | * don't exit if running unit tests |
| 63 | */ |
| 64 | if (!config) { |
| 65 | /* istanbul ignore next */ |
| 66 | console.log(`No WebdriverIO configuration found in "${process.cwd()}"`) |
| 67 | |
| 68 | /* istanbul ignore next */ |
| 69 | if (!process.env.WDIO_UNIT_TESTS) { |
| 70 | process.exit(0) |
| 71 | } |
| 72 | return configPath |
| 73 | } |
| 74 | |
| 75 | const parsedAnswers = await parseAnswers(false) |
| 76 | await runConfigCmd(parsedAnswers, 'latest') |
| 77 | return configPath |
| 78 | } |
| 79 | |
| 80 | export const parseAnswers = async function (yes: boolean): Promise<ParsedAnswers> { |
| 81 | console.log(CONFIG_HELPER_INTRO) |
no test coverage detected
searching dependent graphs…