|
@ -13,7 +13,6 @@ const t = require('typical') |
|
|
const flatten = require('reduce-flatten') |
|
|
const flatten = require('reduce-flatten') |
|
|
|
|
|
|
|
|
const usage = commandLineUsage(cliOptions.usageData) |
|
|
const usage = commandLineUsage(cliOptions.usageData) |
|
|
const stored = loadConfig('local-web-server') |
|
|
|
|
|
|
|
|
|
|
|
let options |
|
|
let options |
|
|
let isHttps = false |
|
|
let isHttps = false |
|
@ -36,16 +35,14 @@ if (options.misc.help) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const convert = require('koa-convert') |
|
|
|
|
|
const Koa = require('koa') |
|
|
const Koa = require('koa') |
|
|
const app = new Koa() |
|
|
const app = new Koa() |
|
|
const _use = app.use |
|
|
|
|
|
app.use = x => _use.call(app, convert(x)) |
|
|
|
|
|
|
|
|
|
|
|
app.on('error', err => { |
|
|
app.on('error', err => { |
|
|
if (options.server['log-format']) { |
|
|
if (options.server['log-format']) { |
|
|
console.error(ansi.format(err.message, 'red')) |
|
|
console.error(ansi.format(err.message, 'red')) |
|
|
} |
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
const ws = localWebServer({ |
|
|
const ws = localWebServer({ |
|
|
static: { |
|
|
static: { |
|
@ -64,7 +61,6 @@ if (options.misc.help) { |
|
|
log: { |
|
|
log: { |
|
|
format: options.server['log-format'] |
|
|
format: options.server['log-format'] |
|
|
}, |
|
|
}, |
|
|
cacheControl: options.server.cacheControl, |
|
|
|
|
|
compress: options.server.compress, |
|
|
compress: options.server.compress, |
|
|
mime: options.server.mime, |
|
|
mime: options.server.mime, |
|
|
forbid: options.server.forbid, |
|
|
forbid: options.server.forbid, |
|
@ -122,6 +118,7 @@ function onServerUp () { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function collectOptions () { |
|
|
function collectOptions () { |
|
|
|
|
|
const stored = loadConfig('local-web-server') |
|
|
let options = {} |
|
|
let options = {} |
|
|
|
|
|
|
|
|
/* parse command line args */ |
|
|
/* parse command line args */ |
|
|