MCPcopy Index your code
hub / github.com/angular/angular-cli / handler

Function handler

packages/angular/cli/src/command-builder/command-module.ts:97–147  ·  view source on GitHub ↗
(args: ArgumentsCamelCase<T> & OtherOptions)

Source from the content-addressed store, hash-verified

95 abstract run(options: Options<T> & OtherOptions): Promise<number | void> | number | void;
96
97 async handler(args: ArgumentsCamelCase<T> & OtherOptions): Promise<void> {
98 const { _, $0, ...options } = args;
99 const { logger } = this.context;
100
101 // Camelize options as yargs will return the object in kebab-case when camel casing is disabled.
102 const camelCasedOptions: Record<string, unknown> = {};
103 for (const [key, value] of Object.entries(options)) {
104 camelCasedOptions[yargsParser.camelCase(key)] = value;
105 }
106
107 // Set up autocompletion if appropriate.
108 const autocompletionExitCode = await considerSettingUpAutocompletion(this.commandName, logger);
109 if (autocompletionExitCode !== undefined) {
110 process.exitCode = autocompletionExitCode;
111
112 return;
113 }
114
115 // Gather and report analytics.
116 const analytics = await this.getAnalytics();
117 const stopPeriodicFlushes = analytics && analytics.periodFlush();
118
119 let exitCode: number | void | undefined;
120 try {
121 if (analytics) {
122 this.reportCommandRunAnalytics(analytics);
123 this.reportWorkspaceInfoAnalytics(analytics);
124 }
125
126 exitCode = await this.run(camelCasedOptions as Options<T> & OtherOptions);
127 } catch (e) {
128 if (e instanceof schema.SchemaValidationException) {
129 logger.fatal(`Error: ${e.message}`);
130 exitCode = 1;
131 } else if (e instanceof PackageManagerError) {
132 const output = e.stderr || e.stdout;
133 logger.fatal(
134 `Error: Package installation failed: ${e.message}${output ? `\nOutput: ${output}` : ''}`,
135 );
136 exitCode = 1;
137 } else {
138 throw e;
139 }
140 } finally {
141 await stopPeriodicFlushes?.();
142
143 if (typeof exitCode === 'number' && exitCode > 0) {
144 process.exitCode = exitCode;
145 }
146 }
147 }
148
149 @memoize
150 protected async getAnalytics(): Promise<AnalyticsCollector | undefined> {

Callers

nothing calls this directly

Calls 5

periodFlushMethod · 0.80
runMethod · 0.65
fatalMethod · 0.65
entriesMethod · 0.45

Tested by

no test coverage detected