| 547 | export type PlatformSwitch<T> = T | { posix: T; win32: T }; |
| 548 | |
| 549 | export function platformDispatch<T>(platform: NodeJS.Platform, platformSwitch: PlatformSwitch<T>) { |
| 550 | if (platformSwitch && typeof platformSwitch === 'object' && 'win32' in platformSwitch) { |
| 551 | return platform === 'win32' ? platformSwitch.win32 : platformSwitch.posix; |
| 552 | } |
| 553 | return platformSwitch; |
| 554 | } |
| 555 | |
| 556 | export async function isFile(shellServer: ShellServer, location: string) { |
| 557 | return platformDispatch(shellServer.platform, { |