Reputation: 157
I currently try to develop a Visual Studio Code extension for extension deployment. What my extension should do is install another extension from the Marktplace.
The obvious way to do that (at least i thought it is) is to create a child process and execute
code --install-extension publisher.extension_name
This command usually works fine, but when it gets executed from within the plugin it returns: "Error: Command failed: bad option: --install-extension".
The first thing i thought is that the extension wouldn't execute the command in the right way, so i tried running "dir C:\Users" just as a test and that worked perfectly fine. After that i tried to run
code --list-extensions
but it returned with the same error. So it looks like I am unable to run any command from within the plugin which uses visual studio code itself. Can someone explain this behaviour ? Does anyone know if there is a better way to install an extension from an extension ?
Upvotes: 2
Views: 338
Reputation: 157
So i found a solution: Instead of launching a child process (which doesn't work for whatever reason as described above), I used the vscode API and run my command with:
vscode.window.createTerminal().sendText("code --install-extension your.extension");
I still don't understand why my first idea doesn't work, but this one does. What i should have probably stressed in my question is that the whole purpose of the plugin is to deploy other plugins from the marktplace. The plugin itself is not dependent on another one, so using the package.json as proposed in the comments wasn't possible.
Upvotes: 2