sonarqube-scanner
Advanced tools
Comparing version 2.6.0 to 2.7.0
// Regular users will call 'require('sonarqube-scanner')' - but not here: eat your own dog food! :-) | ||
const sonarqubeScanner = require('./dist/index') | ||
const scanner = require('./dist/index') | ||
// We just run a SonarQube analysis and push it to SonarCloud | ||
// We just run an analysis and push it to SonarCloud | ||
// (No need to pass the server URL and the token, we're using the Travis | ||
// Addon for SonarCloud which does this for you.) | ||
// --------- | ||
sonarqubeScanner( | ||
scanner( | ||
{ | ||
@@ -10,0 +10,0 @@ options: { |
var exec = require('child_process').execFileSync | ||
var log = require('fancy-log') | ||
var prepareExecEnvironment = require('./sonarqube-scanner-executable').prepareExecEnvironment | ||
var sonarQubeExecutable = require('./sonarqube-scanner-executable').getSonarQubeScannerExecutable | ||
var localSonarQubeExecutable = require('./sonarqube-scanner-executable').getLocalSonarQubeScannerExecutable | ||
var prepareExecEnvironment = require('./sonar-scanner-executable').prepareExecEnvironment | ||
var scannerExecutable = require('./sonar-scanner-executable').getSonarScannerExecutable | ||
var localscannerExecutable = require('./sonar-scanner-executable').getLocalSonarScannerExecutable | ||
module.exports = scan | ||
module.exports.cli = scanCLI | ||
module.exports.customScanner = scanUsingCustomSonarQubeScanner | ||
module.exports.customScanner = scanUsingCustomScanner | ||
module.exports.fromParam = fromParam | ||
const version = require('../package.json').version | ||
/* | ||
@@ -22,3 +25,3 @@ * Function used programmatically to trigger an analysis. | ||
function scanCLI(cliArgs, params, callback) { | ||
log('Starting SonarQube analysis...') | ||
log('Starting analysis...') | ||
@@ -29,6 +32,6 @@ // prepare the exec options, most notably with the SQ params | ||
// determine the command to run and execute it | ||
sonarQubeExecutable(sqScannerCommand => { | ||
scannerExecutable(sqScannerCommand => { | ||
try { | ||
exec(sqScannerCommand, cliArgs, optionsExec) | ||
log('SonarQube analysis finished.') | ||
exec(sqScannerCommand, fromParam().concat(cliArgs), optionsExec) | ||
log('Analysis finished.') | ||
callback() | ||
@@ -42,6 +45,6 @@ } catch (error) { | ||
/* | ||
* Alternatively, trigger an analysis with a local install of the SonarQube Scanner. | ||
* Alternatively, trigger an analysis with a local install of the SonarScanner. | ||
*/ | ||
function scanUsingCustomSonarQubeScanner(params, callback) { | ||
log('Starting SonarQube analysis (with local install of the SonarQube Scanner)...') | ||
function scanUsingCustomScanner(params, callback) { | ||
log('Starting analysis (with local install of the SonarScanner)...') | ||
@@ -52,6 +55,6 @@ // prepare the exec options, most notably with the SQ params | ||
// determine the command to run and execute it | ||
localSonarQubeExecutable(sqScannerCommand => { | ||
localscannerExecutable(sqScannerCommand => { | ||
try { | ||
exec(sqScannerCommand, [], optionsExec) | ||
log('SonarQube analysis finished.') | ||
exec(sqScannerCommand, fromParam(), optionsExec) | ||
log('Analysis finished.') | ||
callback() | ||
@@ -63,1 +66,5 @@ } catch (error) { | ||
} | ||
function fromParam() { | ||
return [`--from=ScannerNpm/${version}`] | ||
} |
{ | ||
"name": "sonarqube-scanner", | ||
"description": "SonarQube/SonarCloud Scanner for the JavaScript world", | ||
"version": "2.6.0", | ||
"version": "2.7.0", | ||
"homepage": "https://github.com/bellingard/sonar-scanner-npm", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -36,5 +36,5 @@ # NPM module to run SonarQube/SonarCloud analyses | ||
```javascript | ||
const sonarqubeScanner = require('sonarqube-scanner'); | ||
const scanner = require('sonarqube-scanner'); | ||
sonarqubeScanner( | ||
scanner( | ||
{ | ||
@@ -60,4 +60,4 @@ serverUrl : 'https://sonarqube.mycompany.com', | ||
* `serverUrl` *String* (optional) The URL of the SonarQube server. Defaults to http://localhost:9000 | ||
* `token` *String* (optional) The token used to connect to the SonarQube server. Empty by default. | ||
* `options` *Map* (optional) Used to pass extra parameters for the SonarQube analysis. See the [official documentation](http://redirect.sonarsource.com/doc/analysis-parameters.html) for more details. | ||
* `token` *String* (optional) The token used to connect to the SonarQube/SonarCloud server. Empty by default. | ||
* `options` *Map* (optional) Used to pass extra parameters for the analysis. See the [official documentation](http://redirect.sonarsource.com/doc/analysis-parameters.html) for more details. | ||
* `callback` *Function* (optional) | ||
@@ -81,3 +81,3 @@ Callback (the execution of the analysis is asynchronous). | ||
* If there's a `package.json` file in the folder, it will be read to feed the analysis with basic information (like project name or version) | ||
* If there's a `sonar-project.properties` file in the folder, it will behave like the [original SonarQube Scanner](https://redirect.sonarsource.com/doc/install-configure-scanner.html) | ||
* If there's a `sonar-project.properties` file in the folder, it will behave like the [original SonarScanner](https://redirect.sonarsource.com/doc/install-configure-scanner.html) | ||
* Additional [analysis parameters](https://redirect.sonarsource.com/doc/analysis-parameters.html) can be passed on the command line using the standard `-Dsonar.xxx=yyy` syntax | ||
@@ -90,5 +90,5 @@ * Example: | ||
#### *I constantly get "Impossible to download and extract binary [...] In such situation, the best solution is to install the standard SonarQube Scanner", what can I do?* | ||
#### *I constantly get "Impossible to download and extract binary [...] In such situation, the best solution is to install the standard SonarScanner", what can I do?* | ||
You can install manually the [standard SonarQube Scanner](https://redirect.sonarsource.com/doc/install-configure-scanner.html), | ||
You can install manually the [standard SonarScanner](https://redirect.sonarsource.com/doc/install-configure-scanner.html), | ||
which requires to have a Java Runtime Environment available too (Java 8+). Once this is done, you can replace the 2nd line | ||
@@ -98,3 +98,3 @@ of the example by: | ||
```javascript | ||
var sonarqubeScanner = require('sonarqube-scanner').customScanner; | ||
var scanner = require('sonarqube-scanner').customScanner; | ||
``` | ||
@@ -101,0 +101,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30
601
45515
3