(args = [])
| 21 | * → { show: true } |
| 22 | */ |
| 23 | export function parsePluginArgs(args = []) { |
| 24 | const opts = {} |
| 25 | for (const arg of args) { |
| 26 | if (!arg) continue |
| 27 | for (const segment of arg.split(';')) { |
| 28 | if (!segment) continue |
| 29 | if (segment.includes('=')) { |
| 30 | const eq = segment.indexOf('=') |
| 31 | const key = segment.slice(0, eq) |
| 32 | const value = segment.slice(eq + 1) |
| 33 | opts[key] = coerce(value) |
| 34 | } else { |
| 35 | opts[segment] = true |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | return opts |
| 40 | } |
| 41 | |
| 42 | function coerce(v) { |
| 43 | if (v === 'true') return true |
no test coverage detected