Created
June 27, 2022 03:51
-
-
Save gkweb/5912192ca8a977029d44b070f5525a5d to your computer and use it in GitHub Desktop.
Copy and paste netlify config based on ENV var
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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