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

Function runCommandInTask

src/utils/vscode.ts:169–216  ·  view source on GitHub ↗
({ command, title, errorMessage, callback, rootDir }: RunCommandOptions)

Source from the content-addressed store, hash-verified

167};
168
169async function runCommandInTask({ command, title, errorMessage, callback, rootDir }: RunCommandOptions) {
170 return new Promise<void>((resolve, reject) => {
171 try {
172 // Define a shell execution for the task
173 const shellExecution = new vscode.ShellExecution(
174 command,
175 rootDir ? { cwd: rootDir.path.replace("/package.json", "") } : {}
176 );
177
178 // Create a task definition
179 const taskDefinition = {
180 type: "process",
181 command: command,
182 };
183
184 // Create the task
185 const task = new vscode.Task(taskDefinition, vscode.TaskScope.Workspace, title, "Custom", shellExecution);
186
187 // Listen for task start
188 // const startDisposable = vscode.tasks.onDidStartTaskProcess((e) => {
189 // if (e.execution.task === task) {
190 // console.log(`Task started: ${e.execution.task.name}`);
191 // }
192 // });
193
194 // Listen for task end
195 const endDisposable = vscode.tasks.onDidEndTaskProcess(async (e) => {
196 if (e.exitCode !== 0) {
197 if (errorMessage) {
198 vscode.window.showErrorMessage(errorMessage);
199 }
200 reject();
201 }
202 if (e.execution.task === task && e.exitCode === 0) {
203 //console.log(`Task ended: ${e.execution.task.name}`);
204 await callback?.();
205 }
206 resolve();
207 endDisposable.dispose();
208 });
209
210 // Execute the task
211 vscode.tasks.executeTask(task);
212 } catch (e) {
213 reject();
214 }
215 });
216}
217
218export const askInstallDependenciesPrompt = async (
219 rootDir: vscode.Uri,

Callers 1

runCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected