2023-07-16 09:06:32 +08:00
|
|
|
import { readFile, writeFile } from "fs/promises"
|
|
|
|
|
|
|
|
async function main() {
|
2023-07-20 17:58:51 +08:00
|
|
|
const dockerFiles = ["ubuntu", "arch", "fedora", "ubuntu-mingw", "arch-mingw", "fedora-mingw"]
|
2023-07-16 09:06:32 +08:00
|
|
|
await Promise.all(
|
|
|
|
dockerFiles.map(async (dockerFile) => {
|
|
|
|
const dockerFileContent = await readFile(`./dev/docker/setup-cpp-${dockerFile}.dockerfile`, "utf-8")
|
|
|
|
const builderExample = await readFile(`./dev/docker/${dockerFile}.dockerfile`, "utf-8")
|
|
|
|
|
|
|
|
const modifiedDockerFile = dockerFileContent
|
2023-07-18 01:27:35 +08:00
|
|
|
// load the externally built setup-cpp
|
2023-07-16 09:06:32 +08:00
|
|
|
.replace(/FROM (.*)/g, `FROM $1\n\nCOPY "./dist/legacy" "/usr/lib/setup-cpp/"`)
|
|
|
|
.replace("setup-cpp ", "node /usr/lib/setup-cpp/setup-cpp.js ")
|
2023-07-18 01:27:35 +08:00
|
|
|
// remove the npm install line
|
|
|
|
.replace(/# install setup-cpp\n\s*npm install -g setup-cpp.*/, "")
|
2023-07-16 09:06:32 +08:00
|
|
|
|
|
|
|
// concat the two files
|
|
|
|
const newDockerFileContent = `${modifiedDockerFile}\n${builderExample}`
|
|
|
|
|
|
|
|
// write the new file in dev/docker/__tests__
|
|
|
|
await writeFile(`./dev/docker/__tests__/${dockerFile}.dockerfile`, newDockerFileContent)
|
|
|
|
})
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
await main()
|