From 7666792d92852ccc5350add674521396c3404a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E9=A2=A2?= Date: Sat, 15 Dec 2018 12:18:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BD=93=E5=AD=98=E5=9C=A8=E6=9C=89?= =?UTF-8?q?=E5=A4=9A=E4=B8=AA=E7=9B=B8=E5=90=8C=E7=9A=84=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=B9key=E7=9A=84=E6=97=B6=E5=80=99=20value=E5=B7=B2?= =?UTF-8?q?=E6=9C=80=E5=90=8E=E4=B8=80=E4=B8=AA=E4=B8=BA=E6=9C=80=E7=BB=88?= =?UTF-8?q?=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/utils.js | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/bin/utils.js b/bin/utils.js index 4d56e51..fede348 100644 --- a/bin/utils.js +++ b/bin/utils.js @@ -3,22 +3,24 @@ const consola = require('consola') const { version } = require('../package.json') function getArgv() { + const alias = { + H: 'hostname', + p: 'port', + h: 'help', + e: 'entry', + o: 'output', + d: 'dll', + c: 'config-file', + fd: 'fileDescriptor', + ic: 'injectContext', + cl: 'clear', + v: 'version' + } + const string = ['H', 'c', 'fd', 'e', 'o', 'ic'] const argv = parseArgs(process.argv.slice(2), { - alias: { - H: 'hostname', - p: 'port', - h: 'help', - e: 'entry', - o: 'output', - d: 'dll', - c: 'config-file', - fd: 'fileDescriptor', - ic: 'injectContext', - cl: 'clear', - v: 'version' - }, + alias, boolean: ['h', 'd', 'v', 'cl'], - string: ['H', 'c', 'fd', 'e', 'o', 'ic'], + string, default: { c: 'build.config.json' } @@ -61,6 +63,14 @@ function getArgv() { process.exit(0) } + string.forEach(index => { + if (Array.isArray(argv[index])) { + const value = argv[index][argv[index].length - 1] + argv[index] = value + argv[alias[index]] = value + } + }) + if (argv.clear) { consola.info('clear cache') const rimraf = require('rimraf')