From 0cbae3fc7f6b22f5e49f5a6f2351d756dc3900a9 Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Mon, 20 Jul 2020 14:11:20 +0200 Subject: [PATCH] #101 - Unrecognized "--from" option --- dist/index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dist/index.js b/dist/index.js index 4e849365..3e729f53 100644 --- a/dist/index.js +++ b/dist/index.js @@ -28,7 +28,7 @@ function scanCLI(cliArgs, params, callback) { var optionsExec = prepareExecEnvironment(params, process) // determine the command to run and execute it - scannerExecutable(sqScannerCommand => { + scannerExecutable((sqScannerCommand) => { try { exec(sqScannerCommand, fromParam().concat(cliArgs), optionsExec) log('Analysis finished.') @@ -49,7 +49,7 @@ function scanUsingCustomScanner(params, callback) { var optionsExec = prepareExecEnvironment(params, process) // determine the command to run and execute it - localscannerExecutable(sqScannerCommand => { + localscannerExecutable((sqScannerCommand) => { try { exec(sqScannerCommand, fromParam(), optionsExec) log('Analysis finished.') @@ -61,5 +61,11 @@ function scanUsingCustomScanner(params, callback) { } function fromParam() { - return [`--from=ScannerNpm/${version}`] + const forcedScannerCLIVersion = process.env.SONAR_SCANNER_VERSION || process.env.npm_config_sonar_scanner_version + if (forcedScannerCLIVersion && forcedScannerCLIVersion < '4.4') { + // When the scanner version is forced through SONAR_SCANNER_VERSION, and version is less than 4.4, don't use the scanner identity parameter + return [] + } else { + return [`--from=ScannerNpm/${version}`] + } }