Skip to content

Commit

Permalink
feat: 当存在有多个相同的配置项key的时候 value已最后一个为最终结果
Browse files Browse the repository at this point in the history
  • Loading branch information
孙颢 committed Dec 15, 2018
1 parent 6936f23 commit 7666792
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions bin/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 7666792

Please sign in to comment.