fix(app): open in powershell (#15112)
This commit is contained in:
@@ -18,6 +18,7 @@ export const commands = {
|
||||
checkAppExists: (appName: string) => __TAURI_INVOKE<boolean>("check_app_exists", { appName }),
|
||||
wslPath: (path: string, mode: "windows" | "linux" | null) => __TAURI_INVOKE<string>("wsl_path", { path, mode }),
|
||||
resolveAppPath: (appName: string) => __TAURI_INVOKE<string | null>("resolve_app_path", { appName }),
|
||||
openInPowershell: (path: string) => __TAURI_INVOKE<null>("open_in_powershell", { path }),
|
||||
};
|
||||
|
||||
/** Events */
|
||||
|
||||
@@ -118,7 +118,6 @@ const createPlatform = (): Platform => {
|
||||
async openPath(path: string, app?: string) {
|
||||
const os = ostype()
|
||||
if (os === "windows") {
|
||||
const resolvedApp = (app && (await commands.resolveAppPath(app))) || app
|
||||
const resolvedPath = await (async () => {
|
||||
if (window.__OPENCODE__?.wsl) {
|
||||
const converted = await commands.wslPath(path, "windows").catch(() => null)
|
||||
@@ -127,6 +126,16 @@ const createPlatform = (): Platform => {
|
||||
|
||||
return path
|
||||
})()
|
||||
const resolvedApp = (app && (await commands.resolveAppPath(app))) || app
|
||||
const isPowershell = (value?: string) => {
|
||||
if (!value) return false
|
||||
const name = value.toLowerCase().replaceAll("/", "\\").split("\\").pop()
|
||||
return name === "powershell" || name === "powershell.exe"
|
||||
}
|
||||
if (isPowershell(resolvedApp)) {
|
||||
await commands.openInPowershell(resolvedPath)
|
||||
return
|
||||
}
|
||||
return openerOpenPath(resolvedPath, resolvedApp)
|
||||
}
|
||||
return openerOpenPath(path, app)
|
||||
|
||||
Reference in New Issue
Block a user