Alex
Alex

Reputation: 67533

How do I RELIABLY get path to vscode User directory from extension?

User is a directory that contains: snippets.json, keybindings.json, settings.json...

Mac/Windows/Linux OS

System/User level installation

Stable/Insiders/Exploration/OSS

installs all have different paths.

I want to get it just like vscode.env.appRoot works. Is it possible?

Upvotes: 1

Views: 439

Answers (2)

Alex
Alex

Reputation: 67533

This seems to be working:

const UserDirectoryPath = path.join(extensionContext.logPath, '../../../..', 'User');

Upvotes: 1

Mike Lischke
Mike Lischke

Reputation: 53317

In you activation function for your extension you'll get an ExtensionContext instance, which has a property extensionPath.

Upvotes: 0

Related Questions