8000 Replace require with extension handling (#5070) · PowerShell/vscode-powershell@9471227 · GitHub
[go: up one dir, main page]

Skip to content
< 8000 script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/sessions-1e75b15ae60a.js">

Commit 9471227

Browse files
authored
Replace require with extension handling (#5070)
package.json information is now available as part of the extension context, this is a minor refactor that saves an additional disk trip.
1 parent 69e3209 commit 9471227

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/extension.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ import { getSettings } from "./settings";
2626
import { PowerShellLanguageId } from "./utils";
2727
import { LanguageClientConsumer } from "./languageClientConsumer";
2828

29-
// The most reliable way to get the name and version of the current extension.
30-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-var-requires
31-
const PackageJSON: any = require("../package.json");
32-
3329
// The 1DS telemetry key, which is just shared among all Microsoft extensions
3430
// (and isn't sensitive).
3531
const TELEMETRY_KEY = "0c6ae279ed8443289764825290e4f9e2-1a736e7c-1324-4338-be46-fc2a58ae4d14-7255";
@@ -115,15 +111,23 @@ export async function activate(context: vscode.ExtensionContext): Promise<IPower
115111
],
116112
});
117113

114+
interface IPackageInfo {
115+
name: string;
116+
displayName: string;
117+
version: string;
118+
publisher: string;
119+
}
120+
const packageInfo:IPackageInfo = context.extension.packageJSON;
121+
118122
sessionManager = new SessionManager(
119123
context,
120124
settings,
121125
logger,
122126
documentSelector,
123-
PackageJSON.name,
124-
PackageJSON.displayName,
125-
PackageJSON.version,
126-
PackageJSON.publisher,
127+
packageInfo.name,
128+
packageInfo.displayName,
129+
packageInfo.version,
130+
packageInfo.publisher,
127131
telemetryReporter);
128132

129133
// Register commands that do not require Language client
< 36EE button class="Button Button--iconOnly Button--invisible ExpandableHunkHeaderDiffLine-module__expand-button-line--rnQN5 ExpandableHunkHeaderDiffLine-module__expand-button-unified--j86KQ" aria-label="Expand file down from line 133" data-direction="down" aria-hidden="true" tabindex="-1">

0 commit comments

Comments
 (0)
0