(obj: Record<string, string | number | boolean | undefined>)
| 5 | * to `false`, so they will only be added to the array if the value is `true`. |
| 6 | */ |
| 7 | export const argify = (obj: Record<string, string | number | boolean | undefined>): string[] => { |
| 8 | const args: string[] = []; |
| 9 | for (const [key, value] of Object.entries(obj)) { |
| 10 | if (value === true) { |
| 11 | args.push(`--${key}`); |
| 12 | } else if (value === false || value === undefined) { |
| 13 | continue; |
| 14 | } else { |
| 15 | args.push(`--${key}`, String(value)); |
| 16 | } |
| 17 | } |
| 18 | return args; |
| 19 | }; |
| 20 | |
| 21 | /** |
| 22 | * Converts a string to kebab-case. |
no test coverage detected