aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--package.json1
-rw-r--r--src/dargs.js17
2 files changed, 5 insertions, 13 deletions
diff --git a/package.json b/package.json
index 66d4395..f48fa23 100644
--- a/package.json
+++ b/package.json
@@ -38,6 +38,7 @@
38 "bluebird": "^3.3.5", 38 "bluebird": "^3.3.5",
39 "chalk": "^1.1.3", 39 "chalk": "^1.1.3",
40 "cross-spawn": "^3.0.1", 40 "cross-spawn": "^3.0.1",
41 "dargs": "^5.1.0",
41 "debug": "^2.2.0", 42 "debug": "^2.2.0",
42 "globby": "^4.0.0", 43 "globby": "^4.0.0",
43 "js-string-escape": "^1.0.1", 44 "js-string-escape": "^1.0.1",
diff --git a/src/dargs.js b/src/dargs.js
index e5c574c..de049ba 100644
--- a/src/dargs.js
+++ b/src/dargs.js
@@ -1,16 +1,7 @@
1'use strict'; 1'use strict';
2 2
3function dargs(obj) { 3const dargs = require('dargs');
4 return Object.keys(obj).reduce((args, key) => {
5 const arg = '--' + key.replace(/[A-Z]/g, '-$&').toLowerCase();
6 const val = obj[key]
7 4
8 if (key === '_') val.forEach(v => args.push(v)) 5module.exports = function(obj){
9 else if (Array.isArray(val)) val.forEach(v => args.push(arg, v)) 6 return dargs(obj, {ignoreFalse: true});
10 else args.push(arg, obj[key]) 7};
11
12 return args.filter(arg => (typeof arg !== 'boolean'))
13 }, [])
14}
15
16module.exports = dargs;