-
Notifications
You must be signed in to change notification settings - Fork 348
/
setbootversion.js
68 lines (59 loc) · 1.7 KB
/
setbootversion.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Sets all boot versions
// Usage: node ./setbootversion.js BOOT_VERSION JAVA_VERSION
//
var path = require('path')
var fs = require('fs')
function recFindPom(base,files,result)
{
files = files || fs.readdirSync(base)
result = result || []
files.forEach(
function (file) {
var newbase = path.join(base,file)
if ( fs.statSync(newbase).isDirectory() )
{
result = recFindPom(newbase,fs.readdirSync(newbase),result)
}
else
{
if ( file === 'pom.xml' && !newbase.includes('target') )
{
result.push(newbase)
}
}
}
)
return result
}
pom_file_list = recFindPom('.');
var newVersion = process.argv[2];
var newJavaVersion = process.argv[3];
for(let pom of pom_file_list) {
var text = fs.readFileSync(pom).toString('utf-8');
var textByLine = text.split("\n");
var inParent = false;
var pomContents = "";
for(let line of textByLine) {
if (line.includes('<parent>')) {
inParent = true;
}
if (line.includes('taco-cloud-parent')) {
inParent = false;
}
if (line.includes('<version>') && inParent) {
line = line.replace(/version>.*<\/version/, 'version>' + newVersion + '</version');
inParent = false;
}
if (line.includes('</version>')) {
inParent = false;
}
if (line.includes('<java.version>')) {
line = line.replace(/java\.version>.*<\/java\.version/, 'java\.version>' + newJavaVersion + '</java\.version');
}
pomContents += line + "\n";
}
fs.writeFile(pom, pomContents, (err) => {
// In case of a error throw err.
if (err) throw err;
}) ;
}