Skip to content

Commit

Permalink
chore: types
Browse files Browse the repository at this point in the history
  • Loading branch information
hongaar authored Oct 18, 2024
1 parent c09c848 commit 0264302
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/core/src/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ export async function task<T>(
callback: (spinner: Ora) => Promise<T>,
) {
const spinner = ora(title).start();
let result: T | null = null;
let result: T;
let error: any;

tasks.push(spinner);

try {
result = await callback(spinner);
} catch (err: any) {
error = error;
error = err;
logError(err);
}

Expand All @@ -117,10 +117,7 @@ export async function task<T>(
flushLogs();
tasks = tasks.filter((task) => task !== spinner);

return [
error ? null : (result as T),
error ? (error as Error) : null,
] as const;
return error ? ([null, error as Error] as const) : ([result!, null] as const);
}

export function getMessages() {
Expand Down

0 comments on commit 0264302

Please sign in to comment.