Skip to content

Instantly share code, notes, and snippets.

@doug2k1
Created May 7, 2020 19:17
Show Gist options
  • Save doug2k1/0b5c6383c63377ddf398ac385d0fdd8d to your computer and use it in GitHub Desktop.
Save doug2k1/0b5c6383c63377ddf398ac385d0fdd8d to your computer and use it in GitHub Desktop.
Create JSON from template
{
"name": "Test",
"baseURL": "__baseURL__",
"otherBaseURL": "__baseURL__"
}
const fs = require("fs")
async function create(baseURL) {
const tmpl = await fs.promises.readFile("./config-template.json", "utf-8")
const contents = tmpl.replace(/__baseURL__/g, baseURL)
await fs.promises.writeFile("./config.json", contents)
}
create("http://localhost:5000")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment