From 004f80864208bd8bad702744d8047d3be5568f99 Mon Sep 17 00:00:00 2001 From: Lloyd Brookes Date: Tue, 8 Dec 2015 23:24:19 +0000 Subject: [PATCH] static and serveIndex default directories added to programmatic API path.resolve used on mock module path to guarantee absolute path. Fixes #25 --- lib/local-web-server.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/local-web-server.js b/lib/local-web-server.js index 7972c1f..9db986b 100644 --- a/lib/local-web-server.js +++ b/lib/local-web-server.js @@ -59,6 +59,8 @@ function localWebServer (options) { 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.forbid = arrayify(options.forbid) options.mocks = arrayify(options.mocks) @@ -148,7 +150,7 @@ function localWebServer (options) { /* Mock Responses */ options.mocks.forEach(mock => { 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) {