From: eric thul Date: Sat, 5 Nov 2016 18:15:58 +0000 (-0400) Subject: Adding dargs dependency X-Git-Tag: 2.0.1~1 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=5f2b3d93a5e4e21e48544be7b4098e38b3fdb2a6;p=github%2Ffretlink%2Fpurs-loader.git Adding dargs dependency See issue #69 --- diff --git a/package.json b/package.json index 66d4395..f48fa23 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "bluebird": "^3.3.5", "chalk": "^1.1.3", "cross-spawn": "^3.0.1", + "dargs": "^5.1.0", "debug": "^2.2.0", "globby": "^4.0.0", "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 @@ 'use strict'; -function dargs(obj) { - return Object.keys(obj).reduce((args, key) => { - const arg = '--' + key.replace(/[A-Z]/g, '-$&').toLowerCase(); - const val = obj[key] +const dargs = require('dargs'); - if (key === '_') val.forEach(v => args.push(v)) - else if (Array.isArray(val)) val.forEach(v => args.push(arg, v)) - else args.push(arg, obj[key]) - - return args.filter(arg => (typeof arg !== 'boolean')) - }, []) -} - -module.exports = dargs; +module.exports = function(obj){ + return dargs(obj, {ignoreFalse: true}); +};