({
editor,
filePath,
line,
}: {
editor: string;
filePath: string;
line: number;
})
| 49 | |
| 50 | /** Build an editor process invocation without shell quoting so paths stay cross-platform. */ |
| 51 | export function buildEditorCommand({ |
| 52 | editor, |
| 53 | filePath, |
| 54 | line, |
| 55 | }: { |
| 56 | editor: string; |
| 57 | filePath: string; |
| 58 | line: number; |
| 59 | }): EditorCommand { |
| 60 | const [command = "", ...editorArgs] = splitEditorCommand(editor); |
| 61 | const program = editorProgram(editor); |
| 62 | |
| 63 | if (VI_STYLE_EDITORS.includes(program)) { |
| 64 | return { command, args: [...editorArgs, `+${line}`, filePath] }; |
| 65 | } |
| 66 | |
| 67 | if (CODE_STYLE_EDITORS.includes(program)) { |
| 68 | return { command, args: [...editorArgs, "--goto", `${filePath}:${line}`] }; |
| 69 | } |
| 70 | |
| 71 | return { command, args: [...editorArgs, filePath] }; |
| 72 | } |
| 73 | |
| 74 | /** Resolve diff paths relative to their source repo instead of the launch cwd. */ |
| 75 | export function resolveEditableFilePath(filePath: string, basePath = process.cwd()) { |
no test coverage detected