mirror of https://github.com/aminya/setup-cpp
27 lines
1.0 KiB
JavaScript
27 lines
1.0 KiB
JavaScript
import { readFile, writeFile } from "fs/promises"
|
|
|
|
async function main() {
|
|
const dockerFiles = ["ubuntu", "arch", "fedora"]
|
|
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
|
|
// 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.*/, "")
|
|
|
|
// 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()
|