( answers: Record<string, PluginAnswer>, key: string, )
| 11 | |
| 12 | /** Extracts a string array from a plugin answer, splitting CSV strings as fallback. */ |
| 13 | export function answerArray( |
| 14 | answers: Record<string, PluginAnswer>, |
| 15 | key: string, |
| 16 | ): string[] { |
| 17 | const value = answers[key]; |
| 18 | if (Array.isArray(value)) { |
| 19 | return value; |
| 20 | } |
| 21 | return (typeof value === 'string' ? value : '') |
| 22 | .split(',') |
| 23 | .map(item => item.trim()) |
| 24 | .filter(Boolean); |
| 25 | } |
| 26 | |
| 27 | /** Extracts a non-empty string array from a plugin answer, using a default if empty. */ |
| 28 | export function answerNonEmptyArray( |
no outgoing calls
no test coverage detected