From d5ece62197ba88b0af166e2bfefc03b03a6c7076 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 5 Oct 2022 11:28:46 +0200 Subject: [PATCH] Web UI: Fix CF environment detection MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- prepare.js | 6 +++--- src/ui/web/start.js | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/prepare.js b/prepare.js index 7d7472a7..28dda6c6 100644 --- a/prepare.js +++ b/prepare.js @@ -1,6 +1,6 @@ -const isCi = process.env.CI !== undefined; -const isCloudFoundry = process.env.VCAP_APPLICATION !== undefined; -if (!isCloudFoundry && !isCi) { +const isCIEnvironment = process.env.CI !== undefined; +const isCFEnvironment = process.env.VCAP_APPLICATION !== undefined; +if (isCFEnvironment === false && isCIEnvironment === false) { // eslint-disable-next-line node/no-unpublished-require require('husky').install(); } diff --git a/src/ui/web/start.js b/src/ui/web/start.js index 0078cb5e..ed6e3e01 100644 --- a/src/ui/web/start.js +++ b/src/ui/web/start.js @@ -3,7 +3,8 @@ const path = require('path'), http = require('http'), serveStatic = require('serve-static'); -const PORT = process.env.PORT || 3030, +const isCFEnvironment = process.env.VCAP_APPLICATION !== undefined, + PORT = isCFEnvironment ? parseInt(process.env.PORT) : 3030, uiPath = path.join(__dirname, './dist'); const serve = serveStatic(uiPath); -- 2.34.1