-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathutil.js
28 lines (23 loc) · 816 Bytes
/
util.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
const path = require('path');
const GoCD = require(path.resolve('util/gocd'));
const glob = require("glob");
function findGoCDConfigFilesForPlugin(pluginId) {
const matchingFiles = GoCD.getFilePatterns()[pluginId].map((p) => glob.sync(p));
return [].concat.apply([], matchingFiles);
}
function representResult(result) {
if (result.valid) {
console.log("\x1b[32m", "Success! Configurations can be merged successfully with GoCD.");
return;
}
const msg = [
`Failed to merge configurations with GoCD. Errors:`,
...[].concat.apply([], result.errors.map((err, i) => `${i + 1}. ${err}`.replace('\n', '\n').split("\n"))), ''
];
msg.forEach((line) => console.error("\x1b[31m", line));
process.exitCode = 1;
}
module.exports = util = {
findGoCDConfigFilesForPlugin,
representResult
};