-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathfetch-tool-versions.js
More file actions
46 lines (41 loc) · 1.15 KB
/
fetch-tool-versions.js
File metadata and controls
46 lines (41 loc) · 1.15 KB
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
const fs = require("fs")
const fetchVersion = async (repo) => {
try {
const fetch = (await import("node-fetch")).default
const response = await fetch(
`https://api.github.com/repos/${repo}/releases/latest`
)
const data = await response.json()
return data.tag_name
} catch (error) {
console.error(`Error fetching the latest release for ${repo}:`, error)
throw error
}
}
const repos = [
"glacier-modding/G2WwiseDataTool",
"glacier-modding/G2GFxDataTool",
"glacier-modding/RPKG-Tool",
"glacier-modding/rebone",
"glacier-modding/primport",
]
;(async () => {
const versions = {}
let hasError = false
for (const repo of repos) {
try {
const name = repo.split("/").pop()
versions[name] = await fetchVersion(repo)
} catch (error) {
hasError = true
break
}
}
if (!hasError) {
fs.writeFileSync("./tool-versions.json", JSON.stringify(versions))
} else {
console.log(
"One or more versions couldn't be fetched. File will not be changed."
)
}
})()