From: Jérôme Benoit Date: Wed, 5 Oct 2022 09:28:46 +0000 (+0200) Subject: Web UI: Fix CF environment detection X-Git-Tag: v1.1.78~3 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d5ece62197ba88b0af166e2bfefc03b03a6c7076;p=e-mobility-charging-stations-simulator.git Web UI: Fix CF environment detection Signed-off-by: Jérôme Benoit --- 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);