({
checkForUpdates = defaultUpdateChecker,
systemProcess = process,
logStream = defaultLogStream,
getVersion = defaultVersionGetter,
applyConfigToArgv = defaultApplyConfigToArgv,
discoverConfigFiles = defaultConfigDiscovery,
loadJSConfigFile = defaultLoadJSConfigFile,
shouldExitProgram = true,
globalEnv = defaultGlobalEnv,
} = {})
| 237 | } |
| 238 | |
| 239 | async execute({ |
| 240 | checkForUpdates = defaultUpdateChecker, |
| 241 | systemProcess = process, |
| 242 | logStream = defaultLogStream, |
| 243 | getVersion = defaultVersionGetter, |
| 244 | applyConfigToArgv = defaultApplyConfigToArgv, |
| 245 | discoverConfigFiles = defaultConfigDiscovery, |
| 246 | loadJSConfigFile = defaultLoadJSConfigFile, |
| 247 | shouldExitProgram = true, |
| 248 | globalEnv = defaultGlobalEnv, |
| 249 | } = {}) { |
| 250 | this.shouldExitProgram = shouldExitProgram; |
| 251 | this.yargs.exitProcess(this.shouldExitProgram); |
| 252 | |
| 253 | this.cleanupProcessEnvConfigs(systemProcess); |
| 254 | const argv = this.getArguments(); |
| 255 | |
| 256 | const cmd = argv._[0]; |
| 257 | |
| 258 | const version = await getVersion(this.absolutePackageDir); |
| 259 | const runCommand = this.commands[cmd]; |
| 260 | |
| 261 | if (argv.verbose) { |
| 262 | this.enableVerboseMode(logStream, version); |
| 263 | } |
| 264 | |
| 265 | let adjustedArgv = { ...argv, webextVersion: version }; |
| 266 | |
| 267 | try { |
| 268 | if (cmd === undefined) { |
| 269 | throw new UsageError('No sub-command was specified in the args'); |
| 270 | } |
| 271 | if (!runCommand) { |
| 272 | throw new UsageError(`Unknown command: ${cmd}`); |
| 273 | } |
| 274 | if (globalEnv === 'production') { |
| 275 | checkForUpdates({ version }); |
| 276 | } |
| 277 | |
| 278 | const configFiles = []; |
| 279 | |
| 280 | if (argv.configDiscovery) { |
| 281 | log.debug( |
| 282 | 'Discovering config files. ' + 'Set --no-config-discovery to disable', |
| 283 | ); |
| 284 | const discoveredConfigs = await discoverConfigFiles(); |
| 285 | configFiles.push(...discoveredConfigs); |
| 286 | } else { |
| 287 | log.debug('Not discovering config files'); |
| 288 | } |
| 289 | |
| 290 | if (argv.config) { |
| 291 | configFiles.push(path.resolve(argv.config)); |
| 292 | } |
| 293 | |
| 294 | if (configFiles.length) { |
| 295 | const niceFileList = configFiles |
| 296 | .map((f) => f.replace(process.cwd(), '.')) |
no test coverage detected