Browse Source

override server stack

master
Lloyd Brookes 8 years ago
parent
commit
67468d865b
  1. 3
      lib/feature-list.js
  2. 61
      lib/local-web-server.js
  3. 2
      package.json

3
lib/feature-list.js

@ -1,4 +1,7 @@
class FeatureList { class FeatureList {
description () {
return 'Print installed features'
}
execute (options) { execute (options) {
const list = [ const list = [
'lws-log', 'lws-log',

61
lib/local-web-server.js

@ -1,15 +1,13 @@
'use strict' 'use strict'
const Lws = require('lws') const Lws = require('lws')
const Serve = require('lws/lib/command/serve/serve')
/** /**
* @module local-web-server * @module local-web-server
*/ */
/**
* @alias module:local-web-server
*/
class LocalWebServer extends Lws {
constructor (options) {
class WsServe extends Serve {
execute (options, argv) {
const path = require('path') const path = require('path')
let stack = [ let stack = [
'lws-log', 'lws-log',
@ -27,30 +25,53 @@ class LocalWebServer extends Lws {
'lws-index' 'lws-index'
] ]
const moduleDir = path.resolve(__dirname, `../node_modules`) const moduleDir = path.resolve(__dirname, `../node_modules`)
options = Object.assign({ stack, 'module-dir': moduleDir, 'module-prefix': 'lws-' }, options)
super(options)
/* add command */
this.commands.set('feature-list', require('./feature-list'))
options = {
stack,
'module-dir': moduleDir,
'module-prefix': 'lws-'
} }
getVersion () {
const path = require('path')
const pkg = require(path.resolve(__dirname, '..', 'package.json'))
return pkg.version
super.execute(options, argv)
} }
getUsageHeader () {
return {
usage () {
const sections = super.usage()
sections.shift()
sections.shift()
sections.pop()
sections.unshift(
{
header: 'local-web-server', header: 'local-web-server',
content: 'A convenient local web server to support productive, full-stack Javascript development.' content: 'A convenient local web server to support productive, full-stack Javascript development.'
},
{
header: 'Synopsis',
content: [
'$ ws <options>',
'$ ws [underline]{command} <options>'
]
}
)
sections.push({
content: 'Project home: [underline]{https://github.com/lwsjs/local-web-server}'
})
return sections
} }
} }
getUsageFooter () {
return {
content: 'Project home: [underline]{https://github.com/lwsjs/local-web-server}'
/**
* @alias module:local-web-server
*/
class LocalWebServer extends Lws {
constructor (options) {
super (options)
this.commands.add(null, WsServe)
this.commands.add('feature-list', require('./feature-list'))
} }
getVersion () {
const path = require('path')
const pkg = require(path.resolve(__dirname, '..', 'package.json'))
return pkg.version
} }
} }

2
package.json

@ -48,7 +48,7 @@
"lws-mime": "^0.1.0", "lws-mime": "^0.1.0",
"lws-mock-response": "^0.1.0", "lws-mock-response": "^0.1.0",
"lws-rewrite": "^0.1.0", "lws-rewrite": "^0.1.0",
"lws-spa": "^0.1.0",
"lws-spa": "^0.1.2",
"lws-static": "^0.1.1", "lws-static": "^0.1.1",
"lws": "^1.0.0-pre.4" "lws": "^1.0.0-pre.4"
}, },

Loading…
Cancel
Save