]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11522 Update Win analysis command in tutorial
authorWouter Admiraal <wouter.admiraal@sonarsource.com>
Thu, 6 Dec 2018 11:02:13 +0000 (12:02 +0100)
committerSonarTech <sonartech@sonarsource.com>
Tue, 11 Dec 2018 19:20:58 +0000 (20:20 +0100)
Quote -D arguments if the OS is Windows.

server/sonar-web/src/main/js/apps/tutorials/components/commands/ClangGCC.tsx
server/sonar-web/src/main/js/apps/tutorials/components/commands/Other.tsx
server/sonar-web/src/main/js/apps/tutorials/components/commands/__tests__/__snapshots__/ClangGCC-test.tsx.snap
server/sonar-web/src/main/js/apps/tutorials/components/commands/__tests__/__snapshots__/Other-test.tsx.snap
server/sonar-web/src/main/js/apps/tutorials/utils.ts

index 0afc9783def6ce7338fa41a36998019b884aa6e4..9dd9dc42df4030ce97de33f27b9b9d8d953de896 100644 (file)
@@ -23,6 +23,7 @@ import BuildWrapper from './BuildWrapper';
 import CodeSnippet from '../../../../components/common/CodeSnippet';
 import InstanceMessage from '../../../../components/common/InstanceMessage';
 import { translate } from '../../../../helpers/l10n';
+import { quote } from '../../utils';
 
 interface Props {
   host: string;
@@ -42,14 +43,15 @@ const executables: { [key: string]: string } = {
 export default function ClangGCC(props: Props) {
   const command1 = `${executables[props.os]} --out-dir bw-output make clean all`;
 
+  const q = quote(props.os);
   const command2 = [
     props.os === 'win' ? 'sonar-scanner.bat' : 'sonar-scanner',
-    `-Dsonar.projectKey=${props.projectKey}`,
-    props.organization && `-Dsonar.organization=${props.organization}`,
-    '-Dsonar.sources=.',
-    '-Dsonar.cfamily.build-wrapper-output=bw-output',
-    `-Dsonar.host.url=${props.host}`,
-    `-Dsonar.login=${props.token}`
+    '-D' + q(`sonar.projectKey=${props.projectKey}`),
+    props.organization && '-D' + q(`sonar.organization=${props.organization}`),
+    '-D' + q('sonar.sources=.'),
+    '-D' + q('sonar.cfamily.build-wrapper-output=bw-output'),
+    '-D' + q(`sonar.host.url=${props.host}`),
+    '-D' + q(`sonar.login=${props.token}`)
   ];
 
   return (
index 3d0b3b2a718aa17233bf15988302a6a4414facae..4e3dfe145ebbb6f8b3b747476a6ec87aaddb0d2d 100644 (file)
@@ -22,6 +22,7 @@ import SQScanner from './SQScanner';
 import CodeSnippet from '../../../../components/common/CodeSnippet';
 import InstanceMessage from '../../../../components/common/InstanceMessage';
 import { translate } from '../../../../helpers/l10n';
+import { quote } from '../../utils';
 
 interface Props {
   host: string;
@@ -32,13 +33,14 @@ interface Props {
 }
 
 export default function Other(props: Props) {
+  const q = quote(props.os);
   const command = [
     props.os === 'win' ? 'sonar-scanner.bat' : 'sonar-scanner',
-    `-Dsonar.projectKey=${props.projectKey}`,
-    props.organization && `-Dsonar.organization=${props.organization}`,
-    '-Dsonar.sources=.',
-    `-Dsonar.host.url=${props.host}`,
-    `-Dsonar.login=${props.token}`
+    '-D' + q(`sonar.projectKey=${props.projectKey}`),
+    props.organization && '-D' + q(`sonar.organization=${props.organization}`),
+    '-D' + q('sonar.sources=.'),
+    '-D' + q(`sonar.host.url=${props.host}`),
+    '-D' + q(`sonar.login=${props.token}`)
   ];
 
   return (
index 670ebd9b46a59d127879635017462a309b3796e3..7a765aa9112745036b6a2b87adca07e312edbdc5 100644 (file)
@@ -27,12 +27,12 @@ exports[`renders correctly 1`] = `
     snippet={
       Array [
         "sonar-scanner.bat",
-        "-Dsonar.projectKey=projectKey",
+        "-D\\"sonar.projectKey=projectKey\\"",
         undefined,
-        "-Dsonar.sources=.",
-        "-Dsonar.cfamily.build-wrapper-output=bw-output",
-        "-Dsonar.host.url=host",
-        "-Dsonar.login=token",
+        "-D\\"sonar.sources=.\\"",
+        "-D\\"sonar.cfamily.build-wrapper-output=bw-output\\"",
+        "-D\\"sonar.host.url=host\\"",
+        "-D\\"sonar.login=token\\"",
       ]
     }
   />
index 941109e9599a39b52c7143fdfebe5b47db4b4f4c..8fe780fe0948c0f64952499f0d0c5dd556bf6002 100644 (file)
@@ -20,11 +20,11 @@ exports[`renders correctly 1`] = `
     snippet={
       Array [
         "sonar-scanner.bat",
-        "-Dsonar.projectKey=projectKey",
+        "-D\\"sonar.projectKey=projectKey\\"",
         undefined,
-        "-Dsonar.sources=.",
-        "-Dsonar.host.url=host",
-        "-Dsonar.login=token",
+        "-D\\"sonar.sources=.\\"",
+        "-D\\"sonar.host.url=host\\"",
+        "-D\\"sonar.login=token\\"",
       ]
     }
   />
index f84785ef61d4e4ee011fa9a84f5d473358dd44da..5c60bf24f680ba038dd8a206e8e6e005cc2f294e 100644 (file)
@@ -38,3 +38,7 @@ export function isLanguageConfigured(config?: LanguageConfig) {
 
   return isJavaConfigured || isDotNetConfigured || isCFamilyConfigured || isOtherConfigured;
 }
+
+export function quote(os: string): ((s: string) => string) {
+  return os === 'win' ? (s: string) => `"${s}"` : (s: string) => s;
+}