()
| 60 | } |
| 61 | |
| 62 | async function main() { |
| 63 | const allApps = (await getApps()).filter((app) => app.test.type === 'script') |
| 64 | |
| 65 | let selectedApps |
| 66 | let additionalArgs = [] |
| 67 | |
| 68 | // Parse command-line arguments |
| 69 | const argIndex = process.argv.indexOf('--') |
| 70 | if (argIndex !== -1) { |
| 71 | additionalArgs = process.argv.slice(argIndex + 1) |
| 72 | process.argv = process.argv.slice(0, argIndex) |
| 73 | } |
| 74 | |
| 75 | if (process.argv[2]) { |
| 76 | const patterns = process.argv[2].toLowerCase().split(',') |
| 77 | selectedApps = allApps.filter((app) => { |
| 78 | const { exerciseNumber, stepNumber, type } = app |
| 79 | |
| 80 | return patterns.some((pattern) => { |
| 81 | let [patternExercise = '*', patternStep = '*', patternType = '*'] = |
| 82 | pattern.split('.') |
| 83 | |
| 84 | patternExercise ||= '*' |
| 85 | patternStep ||= '*' |
| 86 | patternType ||= '*' |
| 87 | |
| 88 | return ( |
| 89 | (patternExercise === '*' || |
| 90 | exerciseNumber === Number(patternExercise)) && |
| 91 | (patternStep === '*' || stepNumber === Number(patternStep)) && |
| 92 | (patternType === '*' || type.includes(patternType)) |
| 93 | ) |
| 94 | }) |
| 95 | }) |
| 96 | } else { |
| 97 | const displayNameMap = new Map( |
| 98 | allApps.map((app) => [getAppDisplayName(app, allApps), app]), |
| 99 | ) |
| 100 | const choices = displayNameMap.keys() |
| 101 | |
| 102 | const response = await prompt({ |
| 103 | type: 'autocomplete', |
| 104 | name: 'appDisplayNames', |
| 105 | message: 'Select apps to test:', |
| 106 | choices: ['All', ...choices], |
| 107 | multiple: true, |
| 108 | suggest: (input, choices) => { |
| 109 | return matchSorter(choices, input, { keys: ['name'] }) |
| 110 | }, |
| 111 | }) |
| 112 | |
| 113 | selectedApps = response.appDisplayNames.includes('All') |
| 114 | ? allApps |
| 115 | : response.appDisplayNames.map((appDisplayName) => |
| 116 | displayNameMap.get(appDisplayName), |
| 117 | ) |
| 118 | |
| 119 | // Update this block to use process.argv |
no test coverage detected