Comparing version 2.0.0-7 to 2.0.0-8
@@ -46,3 +46,3 @@ const util = require('./lib/util') | ||
*/ | ||
this.middlewareStack = null | ||
this.stack = null | ||
@@ -56,3 +56,2 @@ /** | ||
this.setConfig(config) | ||
this.setStack() | ||
} | ||
@@ -91,6 +90,7 @@ | ||
const Stack = require('./lib/middleware-stack') | ||
let stack = arrayify(this.config.stack).slice() | ||
let stack = this.config.stack | ||
/* convert stack to type MiddlewareStack */ | ||
if (!(stack instanceof Stack)) { | ||
stack = arrayify(this.config.stack).slice() | ||
stack = Stack.from(stack, { | ||
@@ -142,2 +142,3 @@ paths: this.config.moduleDir, | ||
if (!this.server) throw new Error('Create server first') | ||
this.setStack() | ||
const middlewares = this.stack.getMiddlewareFunctions(this.config) | ||
@@ -144,0 +145,0 @@ this.server.on('request', this.getRequestHandler(middlewares)) |
@@ -10,4 +10,4 @@ class LwsCli { | ||
try { | ||
const options = this.getOptions(argv) | ||
const server = this.execute(options) | ||
const config = this.getConfig(argv) | ||
const server = this.execute(config) | ||
if (server) { | ||
@@ -112,2 +112,3 @@ server.on('error', err => { | ||
return { | ||
port: 8000, | ||
moduleDir: [ '.' ], | ||
@@ -121,3 +122,3 @@ modulePrefix: 'lws-' | ||
*/ | ||
getOptions (argv) { | ||
getConfig (argv) { | ||
const util = require('./util') | ||
@@ -137,2 +138,3 @@ const commandLineArgs = require('command-line-args') | ||
}) | ||
this.stack = stack // required by usage() | ||
@@ -181,14 +183,16 @@ const stackDefinitions = stack.getOptionDefinitions() | ||
launchServer (options) { | ||
launchServer (config) { | ||
const Lws = require('../') | ||
const lws = Lws.create(options) | ||
const lws = Lws.create(config) | ||
config = lws.config | ||
const server = lws.server | ||
if (options.open) { | ||
if (config.open) { | ||
const open = require('open') | ||
const tls = require('tls') | ||
const protocol = server instanceof tls.Server ? 'https' : 'http' | ||
const host = options.hostname || '127.0.0.1' | ||
open(`${protocol}://${host}:${options.port}`) | ||
const host = config.hostname || '127.0.0.1' | ||
const url = `${protocol}://${host}:${config.port}` | ||
lws.emit('verbose', 'open', url) | ||
open(url) | ||
} | ||
@@ -195,0 +199,0 @@ |
@@ -15,8 +15,8 @@ /** | ||
} else if (Array.isArray(previousValue) && Array.isArray(newValue) && newValue.length) { | ||
return newValue.slice() | ||
return newValue | ||
/* ignore incoming arrays if empty */ | ||
} else if (Array.isArray(newValue) && !newValue.length) { | ||
return Array.isArray(previousValue) ? previousValue.slice() : previousValue | ||
return previousValue | ||
} else if (!t.isDefined(previousValue) && Array.isArray(newValue)) { | ||
return newValue.slice() | ||
return newValue | ||
} | ||
@@ -23,0 +23,0 @@ } |
{ | ||
"name": "lws", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"version": "2.0.0-7", | ||
"version": "2.0.0-8", | ||
"description": "The modular web server for productive full-stack development", | ||
@@ -6,0 +6,0 @@ "repository": "https://github.com/lwsjs/lws.git", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90856
929