MCPcopy Create free account
hub / github.com/code-pushup/cli / task

Method task

packages/utils/src/lib/logger.ts:205–215  ·  view source on GitHub ↗

* Animates asynchronous work using a spinner. * * Basic logs are supported within the worker function, they will be printed with indentation once the spinner completes. * * In CI environments, the spinner animation is disabled, and inner logs are printed immediately. * * Spinners m

(
    title: string,
    worker: () => Promise<string | { message: string; result: T }>,
  )

Source from the content-addressed store, hash-verified

203 * @param worker Asynchronous implementation. Returned promise determines spinner status and final message. Support for inner logs has some limitations (described above).
204 */
205 async task<T = undefined>(
206 title: string,
207 worker: () => Promise<string | { message: string; result: T }>,
208 ): Promise<T> {
209 const result = await this.#spinner(worker, {
210 pending: title,
211 success: value => (typeof value === 'string' ? value : value.message),
212 failure: error => `${title} → ${ansis.red(String(error))}`,
213 });
214 return typeof result === 'object' ? result.result : (undefined as T);
215 }
216
217 /**
218 * Similar to {@link task}, but spinner texts are formatted as shell commands.

Callers 11

logger-demo.tsFile · 0.80
logger.int.test.tsFile · 0.80
uploadFunction · 0.80
readRcByPathFunction · 0.80
getConfigFunction · 0.80
runLighthouseForUrlFunction · 0.80
getTotalDependenciesFunction · 0.80
analyzeUrlMethod · 0.80
launchBrowserMethod · 0.80
loadSetupScriptFunction · 0.80
runSetupFunction · 0.80

Calls 1

#spinnerMethod · 0.95

Tested by

no test coverage detected