Skip to content

Commit bad298b

Browse files
committed
chore: update comments
1 parent 0d7ad4c commit bad298b

File tree

2 files changed

+22
-29
lines changed

2 files changed

+22
-29
lines changed

src/utils/configureExtensionUtil.ts

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ export async function configureSimpleExtension(
1515
{
1616
configKey,
1717
useShims,
18-
// nodejs on windows default allow only `.exe`, no `.cmd`
19-
// https://github.com/jdx/mise/discussions/4360
2018
windowsShimOnlyEXE = true,
2119
windowsExtOptional = false,
2220
useSymLinks,
@@ -71,27 +69,27 @@ export async function getConfiguredBinPath(
7169
binName = tool.name,
7270
}: {
7371
useShims: boolean;
74-
// extension in windows, it only support `.exe`
72+
// shims on windows which only support `.exe`
7573
windowsShimOnlyEXE: boolean;
76-
// extension in windows, the `.exe` ext is optional
77-
// this help extension like `Deno` make no difference to linux/unix in `settings.json`
74+
// for some tools/extension on windows, the `.exe` ext might be optional
75+
// this can help extensions like `Deno` where `mise which` returns `deno.exe` on windows
7876
windowsExtOptional: boolean;
79-
77+
// if using useSymLinks, a side effect is that a symlink will be created in the `.vscode` directory
8078
useSymLinks: boolean;
8179
tool: MiseTool;
8280
miseConfig: MiseConfig;
8381
binName: string;
8482
},
8583
): Promise<string | undefined> {
86-
let updatedPath = "";
84+
let pathToReturn = "";
8785

8886
if (useShims) {
8987
let shimPath = path.join(miseConfig.dirs.shims, binName);
9088
if (isWindows) {
9189
const mode = (await miseService.getSetting("windows_shim_mode"))?.trim();
9290
if (mode === "file" && windowsShimOnlyEXE) {
9391
logger.error(
94-
`extension tool ${binName} only support \`exe\` in windows, change mise setting \`windows_shim_mode\` to \`symlink\` or \`hardlink\``,
92+
`Extension tool ${binName} only support \`exe\` in windows, change mise setting \`windows_shim_mode\` to \`symlink\` or \`hardlink\``,
9593
);
9694
return undefined;
9795
}
@@ -101,41 +99,36 @@ export async function getConfiguredBinPath(
10199
if (!existsSync(shimPath)) {
102100
return undefined;
103101
}
104-
updatedPath = shimPath;
102+
pathToReturn = shimPath;
105103
} else {
106104
// let mise handle path
107-
// python:
108-
// windows: `python.exe`
109-
// linux: `bin/python`
110-
// ruff:
111-
// windows: `ruff.exe`
112-
// linux: `ruff-x86_64-unknown-linux-musl/ruff`
105+
// node https://github.com/jdx/mise/blob/67f5ea8317bcf26755ef6ff65ed460fa272db9ff/src/plugins/core/node.rs#L217-L223
106+
// python: windows: `python.exe` / linux: `bin/python` (https://github.com/jdx/mise/blob/67f5ea8317bcf26755ef6ff65ed460fa272db9ff/src/plugins/core/python.rs#L30-L36)
107+
// ruff: windows: `ruff.exe / linux: `ruff-x86_64-unknown-linux-musl/ruff`
113108
const binPath = await miseService.which(binName);
114109
if (binPath === undefined) {
115110
return undefined;
116111
}
117-
updatedPath = binPath;
112+
pathToReturn = binPath;
118113
}
119114

120115
if (useSymLinks) {
121116
// some extension like `Deno` `Go` will add `.exe` to binName,
122-
// cannot use `deno`, must `deno.exe`.
123-
// shim name maybe `node.cmd`, keep `.cmd` suffix
124-
// so keep ext same with target path
125-
const ext = path.extname(updatedPath);
117+
// For example, it's not possible to use `deno` in that path name. One must specify `deno.exe`.
118+
// Shim name might end with `.cmd` (example: `node.cmd`), in this case, keep the `.cmd` suffix
119+
// (so keep ext same with target path)
120+
const ext = path.extname(pathToReturn);
126121
const symName = isWindows ? `${binName}${ext}` : binName;
127-
updatedPath = await miseService.createMiseToolSymlink(
122+
pathToReturn = await miseService.createMiseToolSymlink(
128123
symName,
129-
updatedPath,
124+
pathToReturn,
130125
"file",
131126
);
132127
}
133128

134-
if (isWindows && windowsExtOptional) {
135-
updatedPath = updatedPath.replace(/\.[^/\\.]+$/, "");
136-
}
137-
138-
return updatedPath;
129+
return isWindows && windowsExtOptional
130+
? pathToReturn.replace(/\.[^/\\.]+$/, "")
131+
: pathToReturn;
139132
}
140133

141134
export async function configureExtension({

src/utils/supportedExtensions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const SUPPORTED_EXTENSIONS: Array<ConfigurableExtension> = [
7171
}) => {
7272
return configureSimpleExtension(miseService, {
7373
configKey: "deno.path",
74-
// if use `deno`,it will be `deno.exe` on windows
74+
// extension is `deno.exe` on windows
7575
windowsExtOptional: true,
7676
useShims,
7777
useSymLinks: false, // disabled until https://github.com/denoland/vscode_deno/pull/1245 is merged
@@ -223,7 +223,7 @@ export const SUPPORTED_EXTENSIONS: Array<ConfigurableExtension> = [
223223
return configureSimpleExtension(miseService, {
224224
configKey: "debug.javascript.defaultRuntimeExecutable",
225225
useShims,
226-
// support `.cmd`
226+
// NodeJS on windows only allows `.exe`, no `.cmd` by default. See https://github.com/jdx/mise/discussions/4360
227227
windowsShimOnlyEXE: false,
228228
windowsExtOptional: true,
229229
useSymLinks,

0 commit comments

Comments
 (0)