Skip to content

Commit

Permalink
Replace require with extension handling (#5070)
Browse files Browse the repository at this point in the history
package.json information is now available as part of the extension context, this is a minor refactor that saves an additional disk trip.
  • Loading branch information
JustinGrote authored Oct 29, 2024
1 parent 69e3209 commit 9471227
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ import { getSettings } from "./settings";
import { PowerShellLanguageId } from "./utils";
import { LanguageClientConsumer } from "./languageClientConsumer";

// The most reliable way to get the name and version of the current extension.
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-var-requires
const PackageJSON: any = require("../package.json");

// The 1DS telemetry key, which is just shared among all Microsoft extensions
// (and isn't sensitive).
const TELEMETRY_KEY = "0c6ae279ed8443289764825290e4f9e2-1a736e7c-1324-4338-be46-fc2a58ae4d14-7255";
Expand Down Expand Up @@ -115,15 +111,23 @@ export async function activate(context: vscode.ExtensionContext): Promise<IPower
],
});

interface IPackageInfo {
name: string;
displayName: string;
version: string;
publisher: string;
}
const packageInfo:IPackageInfo = context.extension.packageJSON;

sessionManager = new SessionManager(
context,
settings,
logger,
documentSelector,
PackageJSON.name,
PackageJSON.displayName,
PackageJSON.version,
PackageJSON.publisher,
packageInfo.name,
packageInfo.displayName,
packageInfo.version,
packageInfo.publisher,
telemetryReporter);

// Register commands that do not require Language client
Expand Down

0 comments on commit 9471227

Please sign in to comment.