1 | const { gulp } = require('../singleton');
|
2 | const { yargs: y } = require('../singleton');
|
3 |
|
4 | gulp.task('sonar:config', () => {
|
5 | const sonar = require('../lib/scan/sonarqube');
|
6 | const args = y.argv.flags;
|
7 | if (args && args.length > 0) {
|
8 | const argsObj = args.reduce((accumulator, currentValue) => {
|
9 | const index = currentValue.indexOf('=');
|
10 | if (index > 0 && currentValue.indexOf('=', index + 1) < 0 && index !== currentValue.length - 1) {
|
11 | const splitVal = currentValue.split('=');
|
12 | return Object.assign({}, accumulator, {
|
13 | [splitVal[0]]: splitVal[1],
|
14 | });
|
15 | }
|
16 | throw new Error('Invalid args');
|
17 | }, {});
|
18 | return sonar.writeConfigFiles(argsObj);
|
19 | }
|
20 | return sonar.writeConfigFiles(null);
|
21 | });
|