Files
orca/src/main/daemon/wsl-cold-restore-cwd.ts
T
mirror 34fa2cd5ca
Skill update round trip / roundtrip (false, macos-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, macos-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, ubuntu-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, ubuntu-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, ubuntu-latest, symlink, latest) (push) Canceled after 0s
Skill update round trip / roundtrip (false, windows-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, windows-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, macos-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, macos-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, ubuntu-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, ubuntu-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, windows-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, windows-latest, symlink, 1.5.17) (push) Canceled after 0s
source snapshot 2026-09-02
2026-09-02 02:03:16 +08:00

38 lines
1.1 KiB
TypeScript

import { hostname as getHostname } from 'node:os'
import { parseWslUncPath, toWindowsWslPath } from '../../shared/wsl-paths'
export function normalizeWslColdRestoreCwd(args: {
recoveredCwd: string
requestedCwd?: string
wslDistro?: string
platform?: NodeJS.Platform
hostname?: string
}): string | undefined {
if ((args.platform ?? process.platform) !== 'win32' || !args.wslDistro) {
return args.recoveredCwd
}
if (/^[A-Za-z]:[\\/]/.test(args.recoveredCwd)) {
return args.recoveredCwd
}
const wslPath = parseWslUncPath(args.recoveredCwd)
if (wslPath) {
return wslPath.distro.toLowerCase() === args.wslDistro.toLowerCase()
? args.recoveredCwd
: args.requestedCwd
}
if (/^\/(?!\/)/.test(args.recoveredCwd)) {
return toWindowsWslPath(args.recoveredCwd, args.wslDistro)
}
const uncMatch = args.recoveredCwd.match(/^[\\/]{2}([^\\/]+)[\\/]([^\\/]+)([\\/].*)?$/)
if (uncMatch?.[1].toLowerCase() === (args.hostname ?? getHostname()).toLowerCase()) {
const linuxPath = `/${uncMatch[2]}${(uncMatch[3] ?? '').replace(/\\/g, '/')}`
return toWindowsWslPath(linuxPath, args.wslDistro)
}
return args.requestedCwd
}