parameter 'dist' rename to 'from'

This commit is contained in:
陆柯 2019-11-06 14:02:51 +08:00
parent 2a5f295239
commit 4169015794

View File

@ -39,7 +39,7 @@ try {
.option('-H, --host <host>', `Host ip or domain name. Default to ${Config.host}`) .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, --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'}`) .option('-p, --port <port>', `Server port. Default to ${Config.port?Config.port:'80|443'}`)
.option('-d, --dist <dist>', `Distribution folder to serve as webroot. Default to ${Config.dist}`) .option('-f, --from <from>', `Distribution folder to serve as webroot. Default to ${Config.from}`)
.option('--sslType <type>', `SSL provider type. Default to ${Config.sslType}`) .option('--sslType <type>', `SSL provider type. Default to ${Config.sslType}`)
.option('--sslCert <cert>', `SSL certificate file. Default to ${Config.sslCert}`) .option('--sslCert <cert>', `SSL certificate file. Default to ${Config.sslCert}`)
.option('--sslKey <key>', `SSL private key file. Default to ${Config.sslKey}`) .option('--sslKey <key>', `SSL private key file. Default to ${Config.sslKey}`)
@ -50,7 +50,7 @@ try {
Config.host=commander.host || Config.host Config.host=commander.host || Config.host
Config.protocol=commander.protocol || Config.protocol || 'http' 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 Config.port=parseInt(commander.port) || parseInt(Config.port) || (Config.protocol==='http'?80:Config.protocol==='https'?443:undefined) // 端口默认为 http:80, https:443, httpall: 80|443
Config.dist = commander.dist || Config.dist || 'dist' Config.from = commander.from || Config.from || 'dist'
Config.sslType = commander.sslType || Config.sslType Config.sslType = commander.sslType || Config.sslType
Config.sslCert=commander.sslCert || Config.sslCert Config.sslCert=commander.sslCert || Config.sslCert
Config.sslKey=commander.sslKey || Config.sslKey Config.sslKey=commander.sslKey || Config.sslKey
@ -95,7 +95,7 @@ async function init(){ /*** 设置全局对象 ***/
// express.static 找到了具体文件就返回找不到就next() // express.static 找到了具体文件就返回找不到就next()
// 所以,如果 vhost匹配了域名且static找到了文件就结束了。如果 vhost 匹配了域名但static找不到文件就继续往下。 // 所以,如果 vhost匹配了域名且static找到了文件就结束了。如果 vhost 匹配了域名但static找不到文件就继续往下。
if (!wo.Config.vhosts) { if (!wo.Config.vhosts) {
server.use(require('express').static(path.join(process.cwd(), wo.Config.dist), {index: 'index.html'})) server.use(require('express').static(path.join(process.cwd(), wo.Config.from), {index: 'index.html'}))
// server.use(require('serve-favicon')(path.join(process.cwd(), 'public', 'favicon.ico'))) // uncomment after placing your favicon in /public // server.use(require('serve-favicon')(path.join(process.cwd(), 'public', 'favicon.ico'))) // uncomment after placing your favicon in /public
}else { }else {
let vhost = require('vhost') let vhost = require('vhost')