Skip to content

Commit 424ba0c

Browse files
authored
Use vscode.open instead of the opn package (LeetCode-OpenSource#90)
1 parent e257c76 commit 424ba0c

File tree

4 files changed

+9
-21
lines changed

4 files changed

+9
-21
lines changed

package-lock.json

-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@
258258
},
259259
"dependencies": {
260260
"fs-extra": "^6.0.1",
261-
"leetcode-cli": "2.6.1",
262-
"opn": "^5.2.0"
261+
"leetcode-cli": "2.6.1"
263262
}
264263
}

src/leetCodeExecutor.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
// Licensed under the MIT license.
33

44
import * as cp from "child_process";
5-
import * as opn from "opn";
65
import * as path from "path";
76
import * as vscode from "vscode";
87
import { executeCommand, executeCommandWithProgress } from "./utils/cpUtils";
9-
import { DialogOptions } from "./utils/uiUtils";
8+
import { DialogOptions, openUrl } from "./utils/uiUtils";
109
import * as wsl from "./utils/wslUtils";
1110

1211
class LeetCodeExecutor {
@@ -38,7 +37,7 @@ class LeetCodeExecutor {
3837
DialogOptions.open,
3938
);
4039
if (choice === DialogOptions.open) {
41-
opn("https://nodejs.org/");
40+
openUrl("https://nodejs.org/");
4241
}
4342
return false;
4443
}

src/utils/uiUtils.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) jdneo. All rights reserved.
22
// Licensed under the MIT license.
33

4-
import * as opn from "opn";
54
import * as vscode from "vscode";
65
import { isLeetCodeCnEnabled } from "../commands/plugin";
76
import { leetCodeChannel } from "../leetCodeChannel";
@@ -48,9 +47,9 @@ export async function promptForSignIn(): Promise<void> {
4847
break;
4948
case DialogOptions.singUp:
5049
if (isLeetCodeCnEnabled()) {
51-
opn("https://leetcode-cn.com/");
50+
openUrl("https://leetcode-cn.com/");
5251
} else {
53-
opn("https://leetcode.com/");
52+
openUrl("https://leetcode.com/");
5453
}
5554
break;
5655
default:
@@ -70,6 +69,10 @@ export async function showFileSelectDialog(): Promise<vscode.Uri[] | undefined>
7069
return await vscode.window.showOpenDialog(options);
7170
}
7271

72+
export async function openUrl(url: string): Promise<void> {
73+
vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(url));
74+
}
75+
7376
export enum DialogType {
7477
info = "info",
7578
warning = "warning",

0 commit comments

Comments
 (0)