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
38 lines
1.1 KiB
TypeScript
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
|
|
}
|