MCPcopy
hub / github.com/prisma/prisma / createSpinner

Function createSpinner

packages/migrate/src/utils/spinner.ts:26–59  ·  view source on GitHub ↗
(enableOutput = true, oraOptions: Partial<OraOptions> = {})

Source from the content-addressed store, hash-verified

24 * @returns
25 */
26export function createSpinner(enableOutput = true, oraOptions: Partial<OraOptions> = {}) {
27 const actualOptions = { ...defaultOraOptions, ...oraOptions }
28
29 return (text: string): SpinnerStarted => {
30 if (!enableOutput) {
31 return {
32 success: () => {},
33 failure: () => {},
34 }
35 }
36
37 actualOptions.stream?.write('\n')
38 const spinner = ora(actualOptions)
39 spinner.start(text)
40
41 return {
42 /**
43 * Stop the spinner, change it to a green ✔ and persist the current text, or text if provided.
44 * @param textSuccess Will persist text if provided.
45 */
46 success: (textSuccess) => {
47 spinner.succeed(textSuccess)
48 },
49
50 /**
51 * Stop the spinner, change it to a red ✖ and persist the current text, or text if provided.
52 * @param textFailure Will persist text if provided.
53 */
54 failure: (textFailure) => {
55 spinner.fail(textFailure)
56 },
57 }
58 }
59}

Callers 1

parseMethod · 0.90

Calls 3

failMethod · 0.80
writeMethod · 0.65
startMethod · 0.65

Tested by

no test coverage detected