Web UI: Fix CF environment detection
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 5 Oct 2022 09:28:46 +0000 (11:28 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 5 Oct 2022 09:28:46 +0000 (11:28 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
prepare.js
src/ui/web/start.js

index 7d7472a7802bc12d0fedc4c9fccc6b9b7554dc8e..28dda6c6cd19aabc0c55844b7b4abebf38c3b31c 100644 (file)
@@ -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();
 }
index 0078cb5e6d0cb2a1364ec8a145f21f6a486bf241..ed6e3e01ff65c0f81696ba9805a5b622f8c5169c 100644 (file)
@@ -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);