-
Notifications
You must be signed in to change notification settings - Fork 0
/
version-bump.js
29 lines (22 loc) · 939 Bytes
/
version-bump.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
/*
takes the version from VERSION and puts it in all relevant files.
*/
const { Console } = require('console')
const fs = require('fs').promises
fs.readFile("./VERSION").then(version => {
doReplace("openapi.yaml", /version: "(\d+\.\d+\.\d+)"/, `version: "${version}"`)
doReplace("docker-compose.yaml", /lucinda-server:(\d+\.\d+\.\d+)/, `lucinda-server:${version}`)
doReplace("package.json", /"version": "(\d+\.\d+\.\d+)"/, `"version": "${version}"`)
doReplace("Dockerfile", /version="(\d+\.\d+\.\d+)"/, `version="${version}"`)
doReplace("Dockerfile.opt", /version="(\d+\.\d+\.\d+)"/, `version="${version}"`)
})
async function doReplace(file, pattern, replacement) {
try {
const cnt = await fs.readFile(file, "utf-8")
await fs.rename(file, file + ".bak")
await fs.writeFile(file, cnt.replace(pattern, replacement))
console.log("written " + file)
} catch (ex) {
console.log("*** ERROR " + ex)
}
}