forked from bellingard/sonar-scanner-npm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
36 lines (33 loc) · 1.31 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
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 Scanner for the JavaScript world",
"sonar.sources": "dist",
"sonar.tests": "specs",
"sonar.javascript.lcov.reportPath": "coverage/lcov.info"
}
}, callback);
// ----------------------------------------------------
});
gulp.task('test', ['pre-test'], function () {
return gulp.src(['specs/**/*.js'])
.pipe(mocha())
// Creating the reports after tests ran
.pipe(istanbul.writeReports());
});
gulp.task('pre-test', function () {
return gulp.src(['dist/**/*.js'])
// Covering files
.pipe(istanbul())
// Force `require` to return covered files
.pipe(istanbul.hookRequire());
});