Quote -D arguments if the OS is Windows.
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;
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 (
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;
}
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 (
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\\"",
]
}
/>
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\\"",
]
}
/>
return isJavaConfigured || isDotNetConfigured || isCFamilyConfigured || isOtherConfigured;
}
+
+export function quote(os: string): ((s: string) => string) {
+ return os === 'win' ? (s: string) => `"${s}"` : (s: string) => s;
+}