1

I want to get the list of installed extensions for VS Code in code.

Not from the CLI, I want it in code so I can write it to the console for diagnostic purposes in the middle of a unit test that's behaving like things aren't installed. It could be that something isn't yet loaded (or is loaded but isn't ready yet).

I already know how to get a list from the CLI as detailed here How to show the extensions installed in Visual Studio Code?.

Probably there's some command I can use with executeCommand, but I can't find it.

Peter Wone
  • 17,965
  • 12
  • 82
  • 134

1 Answers1

2
const extensions = vscode.extensions.all;  // returns an array

will give you all installed extensions - it does include built-in extensions, like vscode.xml and all other pre-installed language extensions. Not just the extensions you may have manually installed.

You could filter those by their id if you wanted. To remove those starting with vscode. for example.

  let extensions = vscode.extensions.all;
  extensions = extensions.filter(extension => !extension.id.startsWith('vscode.'));

That'll get rid of ~80 of the built-ins, but there are more - there are a few starting with 'ms-code' you might not be interested in.

Mark
  • 143,421
  • 24
  • 428
  • 436
  • Actually the one that interests me starts with mscode (it's the ssh remote workspace extension). This is a great answer, it's exactly what I wanted. – Peter Wone Jul 21 '22 at 05:36