setup-cpp/dev/docker/ci/docker-ci.mjs

22 lines
871 B
JavaScript
Raw Normal View History

import { readFile, writeFile } from "fs/promises"
async function main() {
2024-03-24 15:20:20 +08:00
const names = ["ubuntu-llvm", "arch-llvm", "fedora-llvm", "ubuntu-mingw", "arch-mingw", "fedora-mingw"]
await Promise.all(
2024-03-24 15:20:20 +08:00
names.map(async (name) => {
const dockerFileContent = await readFile(`./dev/docker/setup-cpp/setup-cpp-${name}.dockerfile`, "utf-8")
const modifiedDockerFile = dockerFileContent
// load the externally built setup-cpp
.replace(/FROM (.*)/g, `FROM $1\n\nCOPY "./dist/legacy" "/usr/lib/setup-cpp/"`)
.replace("setup-cpp ", "node /usr/lib/setup-cpp/setup-cpp.js ")
// remove the npm install line
.replace(/# install setup-cpp\n\s*npm install -g setup-cpp.*/, "")
2024-03-24 15:20:20 +08:00
// write the new file in dev/docker/ci
await writeFile(`./dev/docker/ci/${name}.dockerfile`, modifiedDockerFile)
2023-07-25 04:20:04 +08:00
}),
)
}
await main()