From adab03f730402056732dcc27d718bf46a3100308 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sun, 12 Nov 2017 20:28:13 +0200 Subject: [PATCH] Fix test --- src/command-line/index.js | 14 ++++++++++++++ src/server.js | 5 ----- test/server.js | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/command-line/index.js b/src/command-line/index.js index 44170481..a1c5451c 100644 --- a/src/command-line/index.js +++ b/src/command-line/index.js @@ -2,6 +2,8 @@ global.log = require("../log.js"); +const fs = require("fs"); +const path = require("path"); const program = require("commander"); const colors = require("colors/safe"); const Helper = require("../helper"); @@ -22,6 +24,18 @@ if (program.home) { log.warn(`Use the ${colors.green("LOUNGE_HOME")} environment variable instead.`); } +// Check if the app was built before calling setHome as it wants to load manifest.json from the public folder +if (!fs.existsSync(path.join( + __dirname, + "..", + "..", + "public", + "manifest.json" +))) { + log.error(`The client application was not built. Run ${colors.bold("NODE_ENV=production npm run build")} to resolve this.`); + process.exit(1); +} + let home = program.home || process.env.LOUNGE_HOME; if (!home) { diff --git a/src/server.js b/src/server.js index f7497f0d..965e8284 100644 --- a/src/server.js +++ b/src/server.js @@ -32,11 +32,6 @@ module.exports = function() { (Node.js ${colors.green(process.versions.node)} on ${colors.green(process.platform)} ${process.arch})`); log.info(`Configuration file: ${colors.green(Helper.CONFIG_PATH)}`); - if (!fs.existsSync("public/js/bundle.js")) { - log.error(`The client application was not built. Run ${colors.bold("NODE_ENV=production npm run build")} to resolve this.`); - process.exit(); - } - var app = express() .disable("x-powered-by") .use(allRequests) diff --git a/test/server.js b/test/server.js index 4c0e9005..d417bc68 100644 --- a/test/server.js +++ b/test/server.js @@ -23,7 +23,7 @@ describe("Server", () => { request(webURL, (error, response, body) => { expect(error).to.be.null; expect(body).to.include("The Lounge"); - expect(body).to.include("https://thelounge.github.io/"); + expect(body).to.include("js/bundle.js"); done(); });