Skip to content

Start build on the client via ProcessExecution #1095

Open
@nojaf

Description

@nojaf

It has never been really obvious to me that this build

Image

is a watch build and you don't need to run rescript -w in a separate terminal anymore.

What would you think of the idea of running this in the vscode extension (instead of the LSP server) and use the TaskProvider instead.

(something along the lines of)

import * as vscode from 'vscode';

export function activate(context: vscode.ExtensionContext) {

    let disposable = vscode.commands.registerCommand('myExtension.runProcessTask', async () => {
        // Define the command to run
        // On Windows, you might need to specify the full path to echo.
        // For cross-platform compatibility, consider using a nodejs process
        // or checking the platform. For this example, 'echo' works on most systems.
        const command = 'echo';
        const args = ['Hello from VS Code Task (ProcessExecution)!'];

        // Create the task using ProcessExecution
        const task = new vscode.Task(
            { type: 'process', task: 'myProcessTask' }, // Task definition (type changed to 'process')
            vscode.TaskScope.Workspace,              // Task scope
            'My Process Task (ProcessExecution)',    // Task name
            'My Extension',                          // Task source
            new vscode.ProcessExecution(command, args),  // Execution details using ProcessExecution
            {                                        // Presentation options
                reveal: vscode.TaskRevealKind.Always,
                panel: vscode.TaskPanelKind.Dedicated,
                clear: true
            }
        );

        // Execute the task
        try {
            await vscode.tasks.executeTask(task);
        } catch (error: any) {
            vscode.window.showErrorMessage(`Failed to execute task: ${error.message}`);
        }
    });

    context.subscriptions.push(disposable);
}

export function deactivate() {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions