From 75c4f1c6a3f9a398e6a09dc1f098955c135f7238 Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Tue, 26 Jan 2021 20:03:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E7=94=A8=20so.sysconfig(rawConfig)=20?= =?UTF-8?q?=E6=9D=A5=E6=8F=90=E4=BE=9B=E5=9F=BA=E7=A1=80=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=8F=82=E6=95=B0=EF=BC=8C=E4=BB=8E=E8=80=8C=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E4=B8=8D=E6=8F=90=E4=BE=9B=20ConfigBasic.js=20=E7=AD=89?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/server.js b/server.js index 5febbca..b9cfd6b 100644 --- a/server.js +++ b/server.js @@ -1,30 +1,27 @@ const fs = require('fs') const path = require('path') -const Config = Object.assign( - { - commanderOptions: [ - // 命令行里可以接受的参数。将传给 config.js 里的 commander。每个参数的定义格式是 [参数名,参数键,描述],后两者用于传给commander,取值后覆盖掉Config里的同名变量。 - ['protocol', '-P, --protocol ', 'Web Server protocol: http|https|httpall.'], - ['host', '-h, --host ', 'Host IP or domain name, default to localhost.'], +const Config = require('so.sysconfig')({ + commanderOptions: [ + // 命令行里可以接受的参数。将传给 config.js 里的 commander。每个参数的定义格式是 [参数名,参数键,描述],后两者用于传给commander,取值后覆盖掉Config里的同名变量。 + ['protocol', '-P, --protocol ', 'Web Server protocol: http|https|httpall.'], + ['host', '-h, --host ', 'Host IP or domain name, default to localhost.'], - ['port', '-p, --port ', 'HTTP port number.'], - ['from', '-f, --from ', 'Seed list such as \'["http://ip_or_dn:port"]\' or "noseed" to disable seeding.'], - ['env', '-e, --env ', 'Runtime environment: production | development.'], - ], - // 最基础的必须的默认配置,如果用户什么也没有提供 - protocol: 'http', - host: 'localhost', - from: './dist', // local path to serve as webroot - // 如果使用虚拟主机 - /* + ['port', '-p, --port ', 'HTTP port number.'], + ['from', '-f, --from ', 'Seed list such as \'["http://ip_or_dn:port"]\' or "noseed" to disable seeding.'], + ['env', '-e, --env ', 'Runtime environment: production | development.'], + ], + // 最基础的必须的默认配置,如果用户什么也没有提供 + protocol: 'http', + host: 'localhost', + from: './dist', // local path to serve as webroot + // 如果使用虚拟主机 + /* vhosts: [ { webroot: 'dist', webindex: 'index.html', domainList: ['']} ], */ - }, - require('so.sysconfig') -) +}) if (typeof Config.ssl === 'string') { Config.ssl = eval(`(${Config.ssl})`) }