1 | (function () {
|
2 | 'use strict';
|
3 |
|
4 | module.exports = function (grunt) {
|
5 | var glob = require("glob"),
|
6 | path = require('path');
|
7 |
|
8 | |
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | function merge(locations, outputFile, type) {
|
18 | var CURRENT_PATH = '.',
|
19 | resultContent = '';
|
20 |
|
21 |
|
22 | locations.forEach(function (l) {
|
23 | var cwd = (l.cwd || CURRENT_PATH) + path.sep;
|
24 |
|
25 | if (l.reports[type]) {
|
26 | glob.sync(l.reports[type], {cwd: cwd, root: '/'}).forEach(function (file) {
|
27 |
|
28 | var content = grunt.file.read(cwd + file).
|
29 | replace(new RegExp('(SF:)(.*?' + l.src + ')(.*)', 'g'), '$1.' + path.sep + 'src$3');
|
30 |
|
31 |
|
32 | resultContent = resultContent.concat(content);
|
33 | });
|
34 | } else {
|
35 | if (type === 'itCoverage') {
|
36 | grunt.log.warn('No integration coverage report has been specified');
|
37 | } else {
|
38 | grunt.log.warn('No coverage report has been specified');
|
39 | }
|
40 | }
|
41 | });
|
42 |
|
43 | grunt.file.write(outputFile, resultContent, {encoding: 'utf8'});
|
44 | }
|
45 |
|
46 | return {
|
47 | merge: merge
|
48 | };
|
49 |
|
50 | };
|
51 | })(); |
\ | No newline at end of file |