add production configuration
This commit is contained in:
@@ -36,6 +36,7 @@ try {
|
||||
// 载入命令行参数
|
||||
commander
|
||||
.version(Config.VERSION, '-v, --version') // 默认是 -V。如果要 -v,就要加 '-v --version'
|
||||
.option('-e, --env <env>', 'Environment. Default to ' + (Config.env || process.env.NODE_ENV))
|
||||
.option('-H, --host <host>', `Host ip or domain name. Default to ${Config.host}`)
|
||||
.option('-P, --protocol <protocol>', `Web server protocol http|https|httpall|http2https. Default to ${Config.protocol}`)
|
||||
.option('-p, --port <port>', `Server port. Default to ${Config.port?Config.port:'80|443'}`)
|
||||
@@ -47,6 +48,12 @@ try {
|
||||
.parse(process.argv)
|
||||
|
||||
// 把命令行参数 合并入配置。
|
||||
Config.env = commander.env || Config.env || process.env.NODE_ENV
|
||||
if (Config.env === 'production') {
|
||||
Config = deepmerge(Config, Config.production)
|
||||
}
|
||||
delete Config.production
|
||||
|
||||
Config.host=commander.host || Config.host
|
||||
Config.protocol=commander.protocol || Config.protocol || 'http'
|
||||
Config.port=parseInt(commander.port) || parseInt(Config.port) || (Config.protocol==='http'?80:Config.protocol==='https'?443:undefined) // 端口默认为 http:80, https:443, httpall: 80|443
|
||||
|
||||
Reference in New Issue
Block a user