]> source.dussan.org Git - sonarqube.git/commitdiff
Add parameter 'l10nCompiled' in start script to force usage of compiled l10n bundle
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Fri, 25 May 2018 13:50:51 +0000 (15:50 +0200)
committerSonarTech <sonartech@sonarsource.com>
Tue, 12 Jun 2018 18:20:58 +0000 (20:20 +0200)
server/sonar-web/scripts/start.js

index 839fcf48eb923080bef883f99d9f8f79f8606b45..ce3726d43e9fe43245a47ab37701dac24db89df1 100644 (file)
@@ -37,8 +37,10 @@ const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
 const host = process.env.HOST || 'localhost';
 const proxy = process.env.PROXY || 'http://localhost:9000';
 
-const compiler = setupCompiler(host, port, protocol);
+// Force start script to proxy l10n request to the server (can be useful when working with plugins/extensions)
+const l10nCompiledFlag = process.argv.findIndex(val => val === 'l10nCompiled') >= 0;
 
+const compiler = setupCompiler(host, port, protocol);
 runDevServer(compiler, host, port, protocol);
 
 function setupCompiler(host, port, protocol) {
@@ -82,11 +84,13 @@ function runDevServer(compiler, host, port, protocol) {
   const devServer = new WebpackDevServer(compiler, {
     before(app) {
       app.use(errorOverlayMiddleware());
-      app.get('/api/l10n/index', (req, res) => {
-        getMessages()
-          .then(messages => res.json({ effectiveLocale: 'en', messages }))
-          .catch(() => res.status(500));
-      });
+      if (!l10nCompiledFlag) {
+        app.get('/api/l10n/index', (req, res) => {
+          getMessages()
+            .then(messages => res.json({ effectiveLocale: 'en', messages }))
+            .catch(() => res.status(500));
+        });
+      }
     },
     compress: true,
     clientLogLevel: 'none',