(opts = {})
| 7 | |
| 8 | // Validate options and assign default options |
| 9 | export const getOptions = (opts = {}) => { |
| 10 | if (!isPlainObj(opts)) { |
| 11 | throw new TypeError(`Options must be a plain object: ${opts}`) |
| 12 | } |
| 13 | |
| 14 | const { exit, onError = defaultOnError, ...unknownOpts } = opts |
| 15 | |
| 16 | validateExit(exit) |
| 17 | |
| 18 | if (typeof onError !== 'function') { |
| 19 | throw new TypeError(`Option "onError" must be a function: ${onError}`) |
| 20 | } |
| 21 | |
| 22 | validateUnknownOpts(unknownOpts) |
| 23 | |
| 24 | return { exit, onError } |
| 25 | } |
| 26 | |
| 27 | const validateExit = (exit) => { |
| 28 | if (exit !== undefined && typeof exit !== 'boolean') { |
no test coverage detected
searching dependent graphs…