( absolutePath: string, line?: number, env: Record<string, string | undefined> = process.env, platform: NodeJS.Platform = process.platform, )
| 9 | } |
| 10 | |
| 11 | export function openFileCommandFor( |
| 12 | absolutePath: string, |
| 13 | line?: number, |
| 14 | env: Record<string, string | undefined> = process.env, |
| 15 | platform: NodeJS.Platform = process.platform, |
| 16 | ): LaunchCommand { |
| 17 | const editor = resolveEditorCommand(env); |
| 18 | if (editor !== undefined) { |
| 19 | const target = supportsLineTarget(editor) && line !== undefined |
| 20 | ? `${absolutePath}:${line}` |
| 21 | : absolutePath; |
| 22 | return { |
| 23 | command: `${editor} ${quoteShellArg(target, platform)}`, |
| 24 | args: [], |
| 25 | shell: true, |
| 26 | }; |
| 27 | } |
| 28 | |
| 29 | switch (platform) { |
| 30 | case 'darwin': |
| 31 | return { command: 'open', args: [absolutePath] }; |
| 32 | case 'win32': |
| 33 | return { command: 'cmd', args: ['/c', 'start', '""', absolutePath] }; |
| 34 | default: |
| 35 | return { command: 'xdg-open', args: [absolutePath] }; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | export function revealFileCommandFor( |
| 40 | absolutePath: string, |
no test coverage detected