24

Is it possible to invoke a VSCode extension command from a terminal?

I'm aware of the code command and all the switches under the Extensions Management category. However, I do not understand if it's possible to invoke a command implemented within a VSCode extension from the command line or it is required that a user must invoke it from the editor's context?

I cannot seem to find a definitive answer after Googling and searching StackOverflow, so I'm asking as a new question. Any insights?

6
  • I don't think that's possible.. What are you trying to do exactly? Seems like most commands wouldn't make sense to be invoked that way.
    – Gama11
    Commented Jan 28, 2019 at 20:25
  • The extension I'm using allows me to obfuscate the code as an export function. The obfuscation method is not open source, unfortunately, and so to do it the proprietary way requires the extension. For a build process, I thought I might be able to do it. Maybe not?
    – ariestav
    Commented Jan 29, 2019 at 14:07
  • 1
    Hm.. well, VSCode extensions necessarily need to ship with their sources. Couldn't you just dig into them and see what it calls when it does the obfuscation, and then use that directly? ;)
    – Gama11
    Commented Jan 29, 2019 at 14:16
  • Good call. I'll take a look and see. Many thanks.
    – ariestav
    Commented Jan 29, 2019 at 14:17
  • 1
    The vendor software installed a separate, external NodeJS script that accomplished it. I think the extension runs that script when its mapped keyboard shortcut is invoked. So it was possible to just call the script in a shell directly.
    – ariestav
    Commented Feb 19, 2019 at 14:11

1 Answer 1

4

Ugly workaround I can use - https://marketplace.visualstudio.com/items?itemName=gabrielgrinberg.auto-run-command

write config file and start vscode (which should trigger that task, check if file exists, run commands) and close vscode

Sad, that there is no better solution for a while

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.