-
Notifications
You must be signed in to change notification settings - Fork 17
/
get_tdb_release.js
35 lines (30 loc) · 947 Bytes
/
get_tdb_release.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
const https = require('https');
const valueType = process.argv[2];
const branch = process.argv[3];
const options = {
hostname: 'api.github.com',
path: '/repos/TrinityCore/TrinityCore/releases',
headers: { 'User-Agent': 'Mozilla/5.0' }
};
https.get(options, (resp) => {
let data = '';
resp.on('data', (chunk) => {
data += chunk;
});
resp.on('end', () => {
let obj = JSON.parse(data);
for(let i=0; i<obj.length; i++) {
if (obj[i]["target_commitish"] == branch) {
if (valueType == 'path') {
process.stdout.write(obj[i]["assets"][0]["browser_download_url"]);
} else if (valueType == 'file') {
process.stdout.write(obj[i]["assets"][0]["name"]);
}
return;
}
}
});
}).on("error", (err) => {
console.log("Error: " + err.message);
process.exit(1)
});