Answer a question

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?

Answers

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

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐