All files / src/toOpts index.js

100% Statements 11/11
100% Branches 6/6
100% Functions 2/2
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 245x 5x 5x 5x   5x 115x   115x         115x   115x           5x    
const {addRemainingOptsAndPosArgs} = require('./addRemainingOptsAndPosArgs')
const {assignOptsAndPosArgs}       = require('./assignOptsAndPosArgs')
const {verifyCommand}              = require('./verifyCommand')
const {pipe}                       = require('../pipe')
 
const toOpts = (opt = {}) => {
  const {errs: errs2, opt: opt2} = verifyCommand(opt)
 
  const defaultCommand = {
    key: 'default',
    opts: []
  }
 
  const opt3 = opt2 || defaultCommand
 
  return ({errs = [], argv = []} = {errs: [], argv: []}) => pipe(
    assignOptsAndPosArgs(opt3),
    addRemainingOptsAndPosArgs(opt3)
  )({errs: [...errs, ...errs2], argv})
}
 
module.exports = {
  toOpts
}