This repository was archived by the owner on Mar 7, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
packages/ember-cli-sonarqube/lib Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -10,10 +10,15 @@ const logProgress = require('./utils/log-progress');
1010function getSonarConfiguration ( config ) {
1111 const pkgJson = JSON . parse ( fs . readFileSync ( path . join ( config . projectRoot , 'package.json' ) , 'utf8' ) ) ;
1212
13- const sources = ( Array . isArray ( pkgJson . keywords ) && pkgJson . keywords . includes ( 'ember-addon' ) )
13+ let sources = ( Array . isArray ( pkgJson . keywords ) && pkgJson . keywords . includes ( 'ember-addon' ) )
1414 ? 'addon,addon-test-support,public'
1515 : 'app,public' ;
1616
17+ sources = sources
18+ . split ( ',' )
19+ . filter ( ( src ) => fs . existsSync ( path . join ( config . projectRoot , src ) ) )
20+ . join ( ',' ) ;
21+
1722 const executionReport = fs . existsSync ( config . reporterOut ) ? config . reporterOut : undefined ;
1823
1924 const eslintReports = [ config . codeLintOut , config . tmplLintOut ]
@@ -83,3 +88,5 @@ module.exports = function reportSonarMetrics(config) {
8388 sonarqubeScanner ( sonarConfig , resolve ) ;
8489 } ) ;
8590}
91+
92+ module . exports . getSonarConfiguration = getSonarConfiguration ;
Original file line number Diff line number Diff line change 1+ const { getConfiguration } = require ( '@nsf-open/ember-cli-sonarqube/lib/configuration' ) ;
2+ const { getSonarConfiguration } = require ( '@nsf-open/ember-cli-sonarqube/lib/report-metrics' ) ;
3+ const { getTestPackage } = require ( './test-helpers' ) ;
4+
5+
6+ describe ( 'getSonarConfiguration' , function ( ) {
7+ const testPackage = getTestPackage ( 'my-addon' ) ;
8+
9+ afterEach ( function ( ) {
10+ jest . resetModules ( ) ;
11+ return testPackage . reset ( ) ;
12+ } ) ;
13+
14+ it ( 'filters the sources list to only directories that exist' , function ( ) {
15+ const cliConfig = getConfiguration ( testPackage . toPath ( ) , { 'dry-run' : true } ) ;
16+ const sonarConfig = getSonarConfiguration ( cliConfig ) ;
17+
18+ expect ( sonarConfig . options [ 'sonar.sources' ] ) . toEqual ( 'addon' ) ;
19+ } ) ;
20+ } ) ;
You can’t perform that action at this time.
0 commit comments