Skip to content

Commit e2f3701

Browse files
committed
fix: TS compile error: Cannot find name 'id'.
https://github.com/yCodeTech/auto-comment-blocks/actions/runs/16339281667/job/46157703386?pr=12 This error occurs because testing used a hard-coded path to simulate what the `vscode.extensions.getExtension().extensionPath` API would get. Since commit b0a40aa changed the way we get/set the package.json data, this was just an oversight. Since we're already using the path of the extension to get the package.json in `getExtensionPackageJsonData`, we can just leverage this, and properly integrate the path. Fixed by: - Adding the extension path as a new `extensionPath` key in the `packageJSON` data object. - Completely removing the VS Code's `.extensions.getExtension()` API call in `createExtensionData` method and changing it to use the `extensionPath` key in the `packageJsonData` property.
1 parent f08044b commit e2f3701

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/extensionData.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@ export class ExtensionData {
2828
/**
2929
* Get the names, id, and version of this extension from package.json.
3030
*
31-
* @returns {IPackageJson} The package.json data for this extension, plus the new `id`, and `contributes.configuration.namespace` keys.
31+
* @returns {IPackageJson} The package.json data for this extension, with extra custom keys.
3232
*/
3333
private getExtensionPackageJsonData(): IPackageJson {
34-
const packageJSON: IPackageJson = readJsonFile(__dirname + "/../../package.json");
34+
const extensionPath = path.join(__dirname, "../../");
35+
36+
const packageJSON: IPackageJson = readJsonFile(path.join(extensionPath, "package.json"));
3537

3638
// Set the id (publisher.name) into the packageJSON object as a new `id` key.
3739
packageJSON.id = `${packageJSON.publisher}.${packageJSON.name}`;
40+
packageJSON.extensionPath = extensionPath;
3841

3942
// The configuration settings namespace is a shortened version of the extension name.
4043
// We just need to replace "automatic" with "auto" in the name.
@@ -65,8 +68,7 @@ export class ExtensionData {
6568
// The path to the user extensions.
6669
const userExtensionsPath = isWsl
6770
? path.join(vscode.env.appRoot, "../../", "extensions")
68-
: path.join(vscode.extensions.getExtension(id).extensionPath, "../");
69-
71+
: path.join(this.packageJsonData.extensionPath, "../");
7072

7173
// Set the keys and values for the Map.
7274
// The keys will also be used for type inference in VSCode intellisense.

0 commit comments

Comments
 (0)