@astrojs/cli-kit
Advanced tools
Comparing version 0.3.0 to 0.3.1
/// <reference types="node" resolution-mode="require"/> | ||
export declare function spinner({ start, end, while: update, }: { | ||
export declare function spinner({ start, end, onError, while: update, }: { | ||
start: string; | ||
end: string; | ||
onError?: (e: any) => void; | ||
while: (...args: any) => Promise<any>; | ||
@@ -6,0 +7,0 @@ }, { stdin, stdout }?: { |
@@ -95,12 +95,19 @@ import readline from "node:readline"; | ||
} | ||
export async function spinner({ start, end, while: update = () => sleep(100), }, { stdin = process.stdin, stdout = process.stdout } = {}) { | ||
export async function spinner({ start, end, onError, while: update = () => sleep(100), }, { stdin = process.stdin, stdout = process.stdout } = {}) { | ||
const loading = await gradient(chalk.green(start), { stdin, stdout }); | ||
const act = update(); | ||
const tooslow = Object.create(null); | ||
const result = await Promise.race([sleep(500).then(() => tooslow), act]); | ||
if (result === tooslow) { | ||
const loading = await gradient(chalk.green(start), { stdin, stdout }); | ||
await act; | ||
try { | ||
const result = await Promise.race([sleep(500).then(() => tooslow), act]); | ||
if (result === tooslow) { | ||
await act; | ||
} | ||
stdout.write(`${" ".repeat(5)} ${chalk.green("✔")} ${chalk.green(end)}\n`); | ||
} | ||
catch (e) { | ||
onError?.(e); | ||
} | ||
finally { | ||
loading.stop(); | ||
} | ||
stdout.write(`${" ".repeat(5)} ${chalk.green("✔")} ${chalk.green(end)}\n`); | ||
} |
{ | ||
"name": "@astrojs/cli-kit", | ||
"type": "module", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "types": "./dist/index.d.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53965
1676