chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:39:12 +08:00
commit d8dcd5f6d1
8604 changed files with 2479390 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
import ora from "ora";
export async function withSpinner(label, fn, opts = {}) {
const enabled = shouldUseSpinner(opts);
const spinner = enabled
? ora({ text: label, stream: process.stderr }).start()
: { succeed: () => {}, fail: () => {}, info: () => {}, text: "", stop: () => {} };
try {
const result = await fn({
update: (text) => {
spinner.text = text;
},
});
if (enabled) spinner.succeed(label);
return result;
} catch (err) {
if (enabled) spinner.fail(`${label}${err.message}`);
throw err;
}
}
export function shouldUseSpinner(opts = {}) {
if (opts.quiet) return false;
if (opts.output === "json" || opts.output === "jsonl" || opts.output === "csv") return false;
if (!process.stderr.isTTY) return false;
if (process.env.NO_COLOR) return false;
if (process.env.CI) return false;
return true;
}