diff options
author | eric thul <thul.eric@gmail.com> | 2016-11-05 14:15:58 -0400 |
---|---|---|
committer | eric thul <thul.eric@gmail.com> | 2016-11-05 14:15:58 -0400 |
commit | 5f2b3d93a5e4e21e48544be7b4098e38b3fdb2a6 (patch) | |
tree | b54b66b4f92c2a1d8d578f5d8dd43748b72bde38 /src/dargs.js | |
parent | 4b99e432d63e7a0ce8ad8d2184232417853bfd2b (diff) | |
download | purs-loader-5f2b3d93a5e4e21e48544be7b4098e38b3fdb2a6.tar.gz purs-loader-5f2b3d93a5e4e21e48544be7b4098e38b3fdb2a6.tar.zst purs-loader-5f2b3d93a5e4e21e48544be7b4098e38b3fdb2a6.zip |
Adding dargs dependency
See issue #69
Diffstat (limited to 'src/dargs.js')
-rw-r--r-- | src/dargs.js | 17 |
1 files changed, 4 insertions, 13 deletions
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 | ||
3 | function dargs(obj) { | 3 | const 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)) | 5 | module.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 | |||
16 | module.exports = dargs; | ||