(value: string)
| 437 | const SYSTEMD_BARE_VALUE = /^[A-Za-z0-9_@%+=:,./-]+$/; |
| 438 | |
| 439 | const systemdQuote = (value: string): string => { |
| 440 | if (SYSTEMD_BARE_VALUE.test(value)) return value; |
| 441 | const escaped = value |
| 442 | .replaceAll("\\", "\\\\") |
| 443 | .replaceAll('"', '\\"') |
| 444 | .replaceAll("\n", "\\n") |
| 445 | .replaceAll("\r", "\\r") |
| 446 | .replaceAll("\t", "\\t"); |
| 447 | return `"${escaped}"`; |
| 448 | }; |
| 449 | |
| 450 | /** Render a systemd --user unit. Pure (snapshot-tested). */ |
| 451 | export const generateSystemdUnit = (options: SystemdUnitOptions): string => { |
no outgoing calls
no test coverage detected