From da41b8e5d2ce9e4dcaae12b8aedc8040ce445c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TZ=20=7C=20=E5=A4=A9=E7=8C=AA?= Date: Tue, 21 Mar 2017 16:15:57 +0800 Subject: [PATCH] feat: use unparseArgv from common-bin (#45) --- lib/cmd/test.js | 3 +-- lib/command.js | 6 ------ lib/helper.js | 18 ------------------ package.json | 9 +++------ 4 files changed, 4 insertions(+), 32 deletions(-) delete mode 100644 lib/helper.js diff --git a/lib/cmd/test.js b/lib/cmd/test.js index 8c3d6540..a8676d2e 100644 --- a/lib/cmd/test.js +++ b/lib/cmd/test.js @@ -4,7 +4,6 @@ const debug = require('debug')('egg-bin:test'); const fs = require('fs'); const path = require('path'); const globby = require('globby'); -const unparse = require('dargs'); const Command = require('../command'); class TestCommand extends Command { @@ -95,7 +94,7 @@ class TestCommand extends Command { newArgv.t = undefined; newArgv.g = undefined; - return unparse(newArgv); + return this.helper.unparseArgv(newArgv); } } diff --git a/lib/command.js b/lib/command.js index fef96fef..f4b53454 100644 --- a/lib/command.js +++ b/lib/command.js @@ -2,14 +2,8 @@ const BaseCommand = require('common-bin'); const changeCase = require('change-case'); -const helper = require('./helper'); class Command extends BaseCommand { - constructor(rawArgv) { - super(rawArgv); - Object.assign(this.helper, helper); - } - /** * normalize context * @param {Object} context - { cwd, argv, rawArgv } diff --git a/lib/helper.js b/lib/helper.js deleted file mode 100644 index dacf8f8a..00000000 --- a/lib/helper.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -const unparse = require('dargs'); - -/** - * unparse argv then change it to array style - * @method helper#unparseArgv - * @param {Object} argv - yargs style - * @param {Object} [options] - options, see more at https://github.com/sindresorhus/dargs - * @param {Array} [options.includes] - keys or regex of keys to include - * @param {Array} [options.excludes] - keys or regex of keys to exclude - * @return {Array} [ '--debug=7000', '--debug-brk' ] - */ -exports.unparseArgv = function(argv, options = {}) { - // revert argv object to array - // yargs will paser `debug-brk` to `debug-brk` and `debugBrk`, so we need to filter - return [ ...new Set(unparse(argv, options)) ]; -}; diff --git a/package.json b/package.json index fdd3a6f2..dc11aa79 100644 --- a/package.json +++ b/package.json @@ -10,15 +10,12 @@ "dependencies": { "change-case": "^3.0.1", "co-mocha": "^1.2.0", - "common-bin": "^2.1.0", - "dargs": "^5.1.0", + "common-bin": "^2.2.0", "debug": "^2.6.3", - "detect-port": "^1.1.0", + "detect-port": "^1.1.1", "egg-utils": "^2.1.0", - "glob": "^7.1.1", "globby": "^6.1.0", "intelli-espower-loader": "^1.0.1", - "is-type-of": "^1.0.0", "istanbul": "^1.1.0-alpha.1", "mocha": "^3.2.0", "mz-modules": "^1.0.0", @@ -34,7 +31,7 @@ "cross-env": "^3.1.3", "egg-ci": "^1.5.0", "enzyme": "^2.0.0", - "eslint": "^3.17.1", + "eslint": "^3.18.0", "eslint-config-egg": "^3.2.0", "jsdom": "^8.0.1", "mm": "^2.1.0",