Skip to content

Instantly share code, notes, and snippets.

@gkweb
Created June 27, 2022 03:51
Show Gist options
  • Save gkweb/5912192ca8a977029d44b070f5525a5d to your computer and use it in GitHub Desktop.
Save gkweb/5912192ca8a977029d44b070f5525a5d to your computer and use it in GitHub Desktop.
Copy and paste netlify config based on ENV var
import fs from 'fs'
import path from 'path'
// Requires folder structure
// config
// -> netlify
// Run with NETLIFY_CONFIG_FILE=netlify.develop.toml node scripts/copy-netlify-config-to-root.mjs
// ^^ You get the picture
// Simple Copy/Paste utility which supports ENV override
const CONFIG_DIR = path.resolve('./config/netlify/')
const ROOT_DIR = path.resolve('./')
const { NETLIFY_CONFIG_FILE = 'netlify.toml' } = process.env
const FILE = '/' + NETLIFY_CONFIG_FILE
const SOURCE = CONFIG_DIR + FILE
const DEST = ROOT_DIR + '/netlify.toml'
fs.copyFile(SOURCE, DEST, (err) => {
if (err) {
throw err
}
console.log(`${SOURCE} was copied to ${DEST} 🗂🪄`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment