Grimson
Grimson

Reputation: 572

Finding VSCode extension extension id

I am currently writing a vscode extension where I require to bundle some files with the extension and on some command, I need to deploy those files at some destination directory (like building a scaffold). For this purpose, I was looking into using these two functions:

const extensionPath = vscode.extensions.getExtension('extension.id').extensionUri.path;
const destinationPath = vscode.workspace.workspaceFolders[0].uri.path;

However, I had trouble finding the extension.id. If I use vscode.extensions.all to enumerate all the extensions, I see undefined_publisher.<name>. I believe this is because I have not published my extension yet, but in that case I guess the undefined_publisher part might change.

Is there any way I can locate my extension without using the publisher name?

Upvotes: 1

Views: 2182

Answers (1)

Mark
Mark

Reputation: 181050

The ExtensionContext object has path and uri properties.

It is the context from your activate(context) function.

See https://code.visualstudio.com/api/references/vscode-api#ExtensionContext

Upvotes: 2

Related Questions