aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authoreric thul <thul.eric@gmail.com>2016-11-05 14:15:58 -0400
committereric thul <thul.eric@gmail.com>2016-11-05 14:15:58 -0400
commit5f2b3d93a5e4e21e48544be7b4098e38b3fdb2a6 (patch)
treeb54b66b4f92c2a1d8d578f5d8dd43748b72bde38
parent4b99e432d63e7a0ce8ad8d2184232417853bfd2b (diff)
downloadpurs-loader-5f2b3d93a5e4e21e48544be7b4098e38b3fdb2a6.tar.gz
purs-loader-5f2b3d93a5e4e21e48544be7b4098e38b3fdb2a6.tar.zst
purs-loader-5f2b3d93a5e4e21e48544be7b4098e38b3fdb2a6.zip
Adding dargs dependency
See issue #69
-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;