In an extension I am writing, I want to redefine an existing setting in the workspace to point at a script I am packaging with the extension. On a mac this script lives in ~/.vscode/extensions/publisher.name.version/script
for example.
If I assume that this is where the extension lives then in my activate function I can update this value using
export async function activate(context: vscode.ExtensionContext) {
const home = process.env.HOME;
const execLocation = home + "/.vscode/extensions/publisher.name.version/script";
...
and then updating the workspace setting.
However - I would like to access the locally installed extensions location, together with the id and version of my extension - I cannot find the correct setting in VSCode to do this. I would be very grateful if someone knew the correct environment variable so I could access them.
I know it is possible to call code from the command line with the option --extensionHomePath
- I am not sure how to access this variable programmatically.
Also I am not sure how to find the version, publisher and name from the context
parameter - obviously I know these from the package.json
file but it would be nice to be able to access them programmatically if possible.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…