( prefix: string, command: string, )
| 13 | * @returns The properly formatted command string with quoted components |
| 14 | */ |
| 15 | export function formatShellPrefixCommand( |
| 16 | prefix: string, |
| 17 | command: string, |
| 18 | ): string { |
| 19 | // Split on the last space before a dash to separate executable from arguments |
| 20 | const spaceBeforeDash = prefix.lastIndexOf(' -') |
| 21 | if (spaceBeforeDash > 0) { |
| 22 | const execPath = prefix.substring(0, spaceBeforeDash) |
| 23 | const args = prefix.substring(spaceBeforeDash + 1) |
| 24 | return `${quote([execPath])} ${args} ${quote([command])}` |
| 25 | } else { |
| 26 | return `${quote([prefix])} ${quote([command])}` |
| 27 | } |
| 28 | } |
| 29 |
no test coverage detected