Files
hiring-test-one/lib/local-web-server.js

78 lines
1.7 KiB
JavaScript
Raw Normal View History

2015-11-08 22:09:07 +00:00
'use strict'
2017-03-13 23:44:11 +00:00
const Lws = require('lws')
2017-06-10 21:16:08 +01:00
const Serve = require('lws/lib/command/serve')
const path = require('path')
2016-06-16 23:00:07 +01:00
2016-06-20 22:27:55 +01:00
/**
* @module local-web-server
*/
2017-06-05 23:41:17 +01:00
class WsServe extends Serve {
execute (options, argv) {
options = {
2017-06-10 21:16:08 +01:00
stack: [
'lws-log',
'lws-cors',
'lws-json',
'lws-rewrite',
'lws-body-parser',
'lws-blacklist',
'lws-conditional-get',
'lws-mime',
'lws-compress',
'lws-mock-response',
'lws-spa',
'lws-static',
'lws-index'
],
moduleDir: path.resolve(__dirname, `../node_modules`),
2017-06-07 23:30:30 +01:00
modulePrefix: 'lws-'
2017-06-05 23:41:17 +01:00
}
super.execute(options, argv)
}
2017-05-23 11:35:31 +01:00
2017-06-05 23:41:17 +01:00
usage () {
const sections = super.usage()
sections.shift()
sections.shift()
sections.pop()
sections.unshift(
{
header: 'local-web-server',
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
}
}
/**
* @alias module:local-web-server
*/
class LocalWebServer extends Lws {
constructor (options) {
super (options)
2017-06-10 21:16:08 +01:00
/* override default serve command */
2017-06-05 23:41:17 +01:00
this.commands.add(null, WsServe)
2017-06-10 21:16:08 +01:00
/* add feature-list command */
2017-06-05 23:41:17 +01:00
this.commands.add('feature-list', require('./feature-list'))
}
2017-03-16 23:10:06 +00:00
getVersion () {
const pkg = require(path.resolve(__dirname, '..', 'package.json'))
return pkg.version
}
}
module.exports = LocalWebServer