This commit is contained in:
Lloyd Brookes
2016-06-09 22:54:57 +01:00
parent bd182e4ffd
commit 027c25f53f
5 changed files with 78 additions and 104 deletions

View File

@ -8,12 +8,12 @@ const Tool = require('command-line-tool')
const tool = new Tool()
class Cli {
constructor () {
constructor (options) {
this.options = null
this.app = null
this.middleware = null
let options = collectOptions()
options = collectOptions()
this.options = options
if (options.misc.config) {
@ -24,23 +24,8 @@ class Cli {
this.app = app
const MiddlewareStack = require('./middleware-stack')
this.middleware = new MiddlewareStack({
static: {
root: options.server.directory,
options: {
hidden: true
}
},
serveIndex: {
path: options.server.directory,
options: {
icons: true,
hidden: true
}
},
log: {
format: options.server['log-format']
},
this.middleware = new MiddlewareStack(options)
const a = {
compress: options.server.compress,
mime: options.server.mime,
forbid: options.server.forbid,
@ -49,7 +34,7 @@ class Cli {
rewrite: options.server.rewrite,
verbose: options.server.verbose,
mocks: options.server.mocks
})
}
app.on('error', err => {
if (options.server['log-format']) {
@ -121,9 +106,7 @@ function collectOptions () {
const builtIn = {
port: 8000,
directory: process.cwd(),
forbid: [],
rewrite: []
directory: process.cwd()
}
if (options.server.rewrite) {