How to Use spawn during vscode-extension development?

Viewed 171

I want to use spawn to run some bash codes after catching some command from the user.

This is what I tried:

const process = require("child_process");

context.subscriptions.push(vscode.commands.registerCommand("generation.startRun", function() {
    let xx = process.spawn("echo", ["'Hello, world."]);
    xx.stdout.on("data", (data) => {
        vscode.window.showInformationMessage(data.toString());
    });
}));

But unfortunately, nothing happend when I activate this command.

Does spawn function work in some way?

Besides, I don't want to use exec because it always shows weird characters when using ls .etc

0 Answers
Related