Skip to content

Commit 0be47f7

Browse files
thegdsksCopilot
andauthored
Update src/ui/progress.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d8f26b4 commit 0be47f7

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/ui/progress.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,21 @@ export class ProgressIndicator {
6565
}
6666
}
6767

68-
export function withProgress<T>(
68+
export async function withProgress<T>(
6969
message: string,
7070
operation: (progress: ProgressIndicator) => Promise<T>
7171
): Promise<T> {
72-
return new Promise(async (resolve, reject) => {
73-
const progress = new ProgressIndicator(message);
74-
progress.start();
72+
const progress = new ProgressIndicator(message);
73+
progress.start();
7574

76-
try {
77-
const result = await operation(progress);
78-
progress.succeed();
79-
resolve(result);
80-
} catch (error) {
81-
progress.fail();
82-
reject(error);
83-
}
84-
});
75+
try {
76+
const result = await operation(progress);
77+
progress.succeed();
78+
return result;
79+
} catch (error) {
80+
progress.fail();
81+
throw error;
82+
}
8583
}
8684

8785
export const progressFrames = {

0 commit comments

Comments
 (0)