forked from bellingard/sonar-scanner-npm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
48 lines (45 loc) · 1.35 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var gulp = require('gulp')
var istanbul = require('gulp-istanbul')
var mocha = require('gulp-mocha')
// Regular users will call 'require('sonarqube-scanner')' - but not here: eat your own dog food! :-)
var sonarqubeScanner = require('./dist/index')
gulp.task('default', ['test'], function(callback) {
// We just run a SonarQube 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(
{
options: {
'sonar.projectName': 'SonarQube/SonarCloud Scanner for the JavaScript world',
'sonar.sources': 'dist',
'sonar.tests': 'specs'
}
},
callback
)
// ----------------------------------------------------
})
gulp.task('test', ['pre-test'], function() {
let result = gulp
.src(['specs/**/*.js'])
.pipe(
mocha(
process.env.CI && {
reporter: 'mocha-sonarqube-reporter'
}
)
)
// Creating the reports after tests ran
.pipe(istanbul.writeReports())
return result
})
gulp.task('pre-test', function() {
let result = gulp
.src(['dist/**/*.js'])
// Covering files
.pipe(istanbul())
// Force `require` to return covered files
.pipe(istanbul.hookRequire())
return result
})