Skip to content

Commit

Permalink
fix: fix mise use action
Browse files Browse the repository at this point in the history
  • Loading branch information
hverlin committed Dec 20, 2024
1 parent ca99f43 commit cdc5899
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/miseService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
shouldCheckForNewMiseVersion,
updateBinPath,
} from "./configuration";
import { expandPath } from "./utils/fileUtils";
import { expandPath, isWindows } from "./utils/fileUtils";
import { uniqBy } from "./utils/fn";
import { logger } from "./utils/logger";
import { resolveMisePath } from "./utils/miseBinLocator";
Expand Down Expand Up @@ -395,7 +395,10 @@ export class MiseService {

const cmd = ["use"];
if (filename) {
const normalizedPath = filename.replace(/\\/g, "/").replace(/^\//, "");
const normalizedPath = isWindows
? filename.replace(/\\/g, "/").replace(/^\//, "")
: filename;

cmd.push(`--path "${normalizedPath}"`);
}
cmd.push("--rm");
Expand Down
12 changes: 8 additions & 4 deletions src/providers/toolsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ import {
} from "../configuration";
import type { MiseService } from "../miseService";
import { configureExtension } from "../utils/configureExtensionUtil";
import { displayPathRelativeTo, expandPath } from "../utils/fileUtils";
import {
displayPathRelativeTo,
expandPath,
isWindows,
} from "../utils/fileUtils";
import { logger } from "../utils/logger";
import { findToolPosition } from "../utils/miseFileParser";
import { CONFIGURABLE_EXTENSIONS_BY_TOOL_NAME } from "../utils/supportedExtensions";
Expand Down Expand Up @@ -396,9 +400,9 @@ export function registerToolsCommands(
return;
}

const normalizedPath = selectedPath
.replace(/\\/g, "/")
.replace(/^\//, "");
const normalizedPath = isWindows
? selectedPath.replace(/\\/g, "/").replace(/^\//, "")
: selectedPath;

await miseService.runMiseToolActionInConsole(
`use --path ${normalizedPath} ${selectedToolName}`,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/fileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as os from "node:os";
import * as path from "node:path";
import { logger } from "./logger";

const isWindows = os.platform() === "win32";
export const isWindows = os.platform() === "win32";

export function expandPath(filePath: string): string {
const res = path
Expand Down

0 comments on commit cdc5899

Please sign in to comment.