MCPcopy Create free account
hub / github.com/code-forge-io/Remix-Forge / commandWithLoading

Function commandWithLoading

src/utils/vscode.ts:4–41  ·  view source on GitHub ↗
(title: string, action: (...args: any[]) => Promise<void> | void)

Source from the content-addressed store, hash-verified

2
3// biome-ignore lint/suspicious/noExplicitAny: <explanation>
4export const commandWithLoading = async (title: string, action: (...args: any[]) => Promise<void> | void) => {
5 let hasError = false;
6 await vscode.window.withProgress(
7 {
8 location: vscode.ProgressLocation.Notification,
9 title: title,
10 cancellable: false,
11 },
12 async (progress) => {
13 // Show initial notification
14 progress.report({ increment: 0, message: "" });
15
16 // Animate loading state
17 const loadingFrames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
18 let frameIndex = 0;
19
20 const animateLoading = setInterval(() => {
21 progress.report({ increment: 0, message: `${loadingFrames[frameIndex]}` });
22 frameIndex = (frameIndex + 1) % loadingFrames.length;
23 }, 50);
24
25 try {
26 await action();
27 } catch (e) {
28 hasError = true;
29 }
30 // Stop the loading animation
31 clearInterval(animateLoading);
32
33 // Update notification when process is finished
34 progress.report({ increment: 100, message: "" });
35 }
36 );
37 if (!hasError) {
38 vscode.window.showInformationMessage(`${title} executed.`).then(() => {});
39 }
40 return;
41};
42
43export const getWorkspaceUri = () => {
44 const workspaceFolders = vscode.workspace.workspaceFolders;

Callers 3

flattenRoutesFunction · 0.90
generateTestsFunction · 0.90
runCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected