MCPcopy
hub / github.com/mozilla/web-ext / execute

Method execute

src/program.js:239–346  ·  view source on GitHub ↗
({
    checkForUpdates = defaultUpdateChecker,
    systemProcess = process,
    logStream = defaultLogStream,
    getVersion = defaultVersionGetter,
    applyConfigToArgv = defaultApplyConfigToArgv,
    discoverConfigFiles = defaultConfigDiscovery,
    loadJSConfigFile = defaultLoadJSConfigFile,
    shouldExitProgram = true,
    globalEnv = defaultGlobalEnv,
  } = {})

Source from the content-addressed store, hash-verified

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(), '.'))

Callers 2

mainFunction · 0.95
execProgramFunction · 0.80

Calls 10

getArgumentsMethod · 0.95
enableVerboseModeMethod · 0.95
checkForUpdatesFunction · 0.90
discoverConfigFilesFunction · 0.90
loadJSConfigFileFunction · 0.90
applyConfigToArgvFunction · 0.90
getVersionFunction · 0.85
exitMethod · 0.45

Tested by

no test coverage detected