import minimist from 'minimist' ; import commander from 'commander' ; export default ( declaredOptions ) => { const argv = minimist ( process . argv . slice ( 2 ) ) ; const declaredOptionsStrings = declaredOptions . reduce ( ( list , option ) => { const { short = '' , long = '' } = option ; list . push ( short . slice ( 1 ) ) ; list . push ( long . slice ( 2 ) ) ; return list ; } , [ ] ) ; return Object . keys ( argv ) . reduce ( ( unexpectedOptions , key ) => { if ( key !== '_' && ! declaredOptionsStrings . includes ( key ) ) { return { ... unexpectedOptions , [ key ] : argv [ key ] , } ; } return unexpectedOptions ; } , { } ) ; } ;