Browse Source

static and serveIndex default directories added to programmatic API

path.resolve used on mock module path to guarantee absolute path. Fixes #25
master
Lloyd Brookes 9 years ago
parent
commit
004f808642
  1. 4
      lib/local-web-server.js

4
lib/local-web-server.js

@ -59,6 +59,8 @@ function localWebServer (options) {
log.format = 'none' log.format = 'none'
} }
if (!options.static.root) options.static.root = process.cwd()
if (!options.serveIndex.path) options.serveIndex.path = process.cwd()
options.rewrite = arrayify(options.rewrite) options.rewrite = arrayify(options.rewrite)
options.forbid = arrayify(options.forbid) options.forbid = arrayify(options.forbid)
options.mocks = arrayify(options.mocks) options.mocks = arrayify(options.mocks)
@ -148,7 +150,7 @@ function localWebServer (options) {
/* Mock Responses */ /* Mock Responses */
options.mocks.forEach(mock => { options.mocks.forEach(mock => {
if (mock.module) { if (mock.module) {
mock.responses = require(path.join(options.static.root, mock.module))
mock.responses = require(path.resolve(path.join(options.static.root, mock.module)))
} }
if (mock.responses) { if (mock.responses) {

Loading…
Cancel
Save