Browse Source

--version option. Fixes #39.

master
Lloyd Brookes 9 years ago
parent
commit
f21300380a
  1. 6
      lib/cli-data.js
  2. 3
      lib/local-web-server.js
  3. 2
      lib/middleware.js

6
lib/cli-data.js

@ -24,8 +24,12 @@ exports.optionDefinitions = [
description: 'Print the stored config.', group: 'misc' description: 'Print the stored config.', group: 'misc'
}, },
{ {
name: 'verbose', type: Boolean,
name: 'verbose', type: Boolean, alias: 'v',
description: 'Verbose output, useful for debugging.', group: 'misc' description: 'Verbose output, useful for debugging.', group: 'misc'
},
{
name: 'version', type: Boolean,
description: 'Print the version number.', group: 'misc'
} }
] ]

3
lib/local-web-server.js

@ -63,6 +63,9 @@ class LocalWebServer extends MiddlewareStack {
if (options.config) { if (options.config) {
tool.stop(JSON.stringify(options, null, ' '), 0) tool.stop(JSON.stringify(options, null, ' '), 0)
} else if (options.version) {
const pkg = require(path.resolve(__dirname, '..', 'package.json'))
tool.stop(pkg.version)
} else { } else {
const server = this.getServer() const server = this.getServer()
server.listen(options.port, onServerUp.bind(null, options, server.isHttps)) server.listen(options.port, onServerUp.bind(null, options, server.isHttps))

2
lib/middleware.js

@ -83,7 +83,7 @@ function mockResponses (route, targets) {
target = targets.find(target => !target.request) target = targets.find(target => !target.request)
} }
debug(`mock path: ${ctx.path} target: ${target.name || "unnamed"}`)
debug(`mock path: ${ctx.path} target: ${target.name || 'unnamed'}`)
if (target) { if (target) {
if (t.isFunction(target.response)) { if (t.isFunction(target.response)) {

Loading…
Cancel
Save