Skip to content

Commit f2cb8bd

Browse files
author
Jeff Escalante
committed
get rid of argparse nulls once and for all
1 parent feca0fe commit f2cb8bd

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
const EventEmitter = require('events').EventEmitter
66
const ArgumentParser = require('argparse').ArgumentParser
7+
const reduce = require('lodash.reduce')
78
// TODO: this should reflect spike version, or cli should always mirror
89
const pkg = require('../package.json')
910
let Spike = require('spike-core')
@@ -43,6 +44,10 @@ module.exports = class CLI extends EventEmitter {
4344
const fn = require(`./${args.fn}`)
4445
delete args.fn
4546

47+
// argparse uses `null` which doesn't get along with joi, so we remove
48+
// null values here
49+
args = reduce(args, (m, v, k) => { if (v) m[k] = v; return m }, {})
50+
4651
// all CLI modules must return an event emitter of some sort
4752
// they should also wait to execute anything until nextTick
4853
const emitter = fn(Spike, args)

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"dependencies": {
1515
"argparse": "^1.0.6",
1616
"chalk": "^1.1.3",
17-
"spike-core": "^0.2.0"
17+
"lodash.reduce": "^4.4.0",
18+
"spike-core": "^0.2.1"
1819
},
1920
"devDependencies": {
2021
"ava": "^0.14.0",

0 commit comments

Comments
 (0)