Skip to content

Commit e4d9828

Browse files
committed
Fix extension URIs/paths
Signed-off-by: paulober <[email protected]>
1 parent 65cdd72 commit e4d9828

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

src/activator.mts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ import Stubs, {
2121
} from "./stubs.mjs";
2222
import Settings, { SettingsKey } from "./settings.mjs";
2323
import Logger from "./logger.mjs";
24-
import { basename, dirname, extname, join } from "path";
24+
import { basename, extname, join } from "path";
2525
import { PicoRemoteFileSystem } from "./filesystem.mjs";
2626
import { Terminal } from "./terminal.mjs";
27-
import { fileURLToPath } from "url";
2827
import { ContextKeys } from "./models/contextKeys.mjs";
2928
import DeviceWifiProvider from "./activitybar/deviceWifiTree.mjs";
3029
import PackagesWebviewProvider from "./activitybar/packagesWebview.mjs";
@@ -100,7 +99,7 @@ export default class Activator {
10099
true
101100
);
102101

103-
this.stubs = new Stubs();
102+
this.stubs = new Stubs(context.extensionUri);
104103
await this.stubs.update(this.settings);
105104

106105
const workspaceFolder = vscode.workspace.workspaceFolders;
@@ -275,13 +274,10 @@ export default class Activator {
275274

276275
this.terminalOptions = {
277276
name: TERMINAL_NAME,
278-
iconPath: vscode.Uri.file(
279-
join(
280-
dirname(fileURLToPath(import.meta.url)),
281-
"..",
282-
"images",
283-
"logo-256.png"
284-
)
277+
iconPath: vscode.Uri.joinPath(
278+
context.extensionUri,
279+
"images",
280+
"logo-256.png"
285281
),
286282
isTransient: true,
287283
pty: this.terminal,
@@ -1246,7 +1242,7 @@ export default class Activator {
12461242
enableScripts: false,
12471243
// Only allow the webview to access resources in our extension's media directory
12481244
localResourceRoots: [
1249-
vscode.Uri.file(join(context.extensionPath, "images")),
1245+
vscode.Uri.joinPath(context.extensionUri, "images"),
12501246
],
12511247
}
12521248
);

src/stubs.mts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { commands, window } from "vscode";
1+
import { commands, Uri, window } from "vscode";
22
import { join } from "path";
33
import {
44
getProjectPath,
@@ -28,7 +28,7 @@ import { strict as assert } from "assert";
2828
export default class Stubs {
2929
private logger: Logger;
3030

31-
constructor() {
31+
constructor(private readonly extensionUri: Uri) {
3232
this.logger = new Logger("Stubs");
3333
}
3434

@@ -39,6 +39,7 @@ export default class Stubs {
3939
*/
4040
public async update(settings: Settings): Promise<void> {
4141
const installedStubsFolder = getStubsPathForVersion("included");
42+
const currentFolder = Uri.joinPath(this.extensionUri, "mpy_stubs").fsPath;
4243

4344
if (!(await pathExists(join(installedStubsFolder, "version.json")))) {
4445
// ensure config folder exists
@@ -57,8 +58,6 @@ export default class Stubs {
5758
}
5859
}
5960

60-
const currentFolder = join(__dirname, "..", "mpy_stubs");
61-
6261
if (await pathExists(currentFolder)) {
6362
const currentMatchingFolders = (await readdir(currentFolder)).filter(
6463
name => /micropython_rp2.*\.dist-info/.exec(name)
@@ -86,7 +85,7 @@ export default class Stubs {
8685
try {
8786
// update stubs folder
8887
await emptyDir(installedStubsFolder);
89-
await copy(join(__dirname, "..", "mpy_stubs"), installedStubsFolder);
88+
await copy(currentFolder, installedStubsFolder);
9089

9190
this.logger.info("Updated stubs successfully!");
9291

0 commit comments

Comments
 (0)