diff --git a/packages/live-server/index.js b/packages/live-server/index.js index 2fcd40d5c..1a1c12fe3 100644 --- a/packages/live-server/index.js +++ b/packages/live-server/index.js @@ -172,7 +172,8 @@ LiveServer.start = function (options) { const port = options.port !== undefined ? options.port : 8080; // 0 means random const root = options.root || process.cwd(); const mount = options.mount || []; - const watchPaths = options.watch || [root, ...options.assets]; + const watchPaths = + options.watch || (options.assets ? [root, ...options.assets] : [root]); LiveServer.logLevel = options.logLevel === undefined ? 2 : options.logLevel; let openPath = @@ -482,6 +483,9 @@ LiveServer.start = function (options) { }); } }; + + // server needs to get returned for the tests + return server; // eslint-disable-line consistent-return }; LiveServer.shutdown = function () { diff --git a/packages/live-server/live-server.js b/packages/live-server/live-server.js index 3fd1a6115..af62a0883 100755 --- a/packages/live-server/live-server.js +++ b/packages/live-server/live-server.js @@ -90,7 +90,7 @@ for (let i = process.argv.length - 1; i >= 2; --i) { } else if (arg.indexOf('--mount=') > -1) { // e.g. "--mount=/components:./node_modules" will be ['/components', '/node_modules'] // split only on the first ":", as the path may contain ":" as well (e.g. C:\file.txt) - var match = arg.substring(8).match(/([^:]+):(.+)$/); + const match = arg.substring(8).match(/([^:]+):(.+)$/); match[2] = path.resolve(process.cwd(), match[2]); opts.mount.push([match[1], match[2]]); process.argv.splice(i, 1); @@ -119,7 +119,7 @@ for (let i = process.argv.length - 1; i >= 2; --i) { process.argv.splice(i, 1); } else if (arg.indexOf('--proxy=') > -1) { // split only on the first ":", as the URL will contain ":" as well - var match = arg.substring(8).match(/([^:]+):(.+)$/); + const match = arg.substring(8).match(/([^:]+):(.+)$/); opts.proxy.push([match[1], match[2]]); process.argv.splice(i, 1); } else if (arg.indexOf('--middleware=') > -1) { diff --git a/packages/live-server/package.json b/packages/live-server/package.json index ac5b95dec..9489528b3 100644 --- a/packages/live-server/package.json +++ b/packages/live-server/package.json @@ -35,7 +35,7 @@ "scripts": { "lint": "eslint live-server.js index.js", "hint": "jshint live-server.js index.js", - "test:separate": "mocha test && npm run lint" + "test:separate": "mocha test --exit && npm run lint" }, "bin": { "live-server": "./live-server.js" diff --git a/packages/live-server/test/acceptance.js b/packages/live-server/test/acceptance.js index 1e96ee414..299a9e3f0 100644 --- a/packages/live-server/test/acceptance.js +++ b/packages/live-server/test/acceptance.js @@ -35,13 +35,13 @@ describe('basic functional tests', function () { .expect(/