Wednesday, 19 April 2017

Creating a Visual Studio Code integrated terminal with a custom Node script as the shell

I'm working on a Visual Studio Code extension in which I hope to create a terminal which gives access to a custom shell. I have a Node.js script (.js file) which implements this shell. Now, I'm trying to use Code's createTerminal method from my extension to launch a terminal that uses my Node.js script as its shell.

I can't directly set the shellPath to be my js file, because I have no guarantee that the user has Node.js installed, that the system will run such files with Node.js, nor what version of Node is installed. Roughly speaking, I want to do this:

let terminal = vscode.window.createTerminal({
    name: "My terminal",
    shellPath: 'node', // Use the Node.js executable as the target
    shellArgs: [path.join(__dirname, 'my-shell-wrapper.js')] // Tell Node to run my shell
});
terminal.show();

How can I accomplish this? Is there an executable that ships with Code that I can point to which runs Node scripts? Or is there another mechanism which I'm missing?



via Wasabi Fan

No comments:

Post a Comment