Skip to content

Instantly share code, notes, and snippets.

@jwarby
Last active November 25, 2021 05:09
Show Gist options
  • Save jwarby/c20dd56068431cfbe13c6e2cf108147d to your computer and use it in GitHub Desktop.
Save jwarby/c20dd56068431cfbe13c6e2cf108147d to your computer and use it in GitHub Desktop.
Extract Netlify env vars
/* Prints env vars from Netlify deploy settings UI to
* the JavaScript console.
*
* Usage: go to the build & deploy settings section of
* a Netlify site, then run this script.
*/
const envVars = $("#section-environment").querySelectorAll("dl");
const output = [].reduce.call(envVars, (str, dl) => {
const name = dl.querySelector("dt").innerText;
const value = dl.querySelector("dd").innerText;
return str + `${name}=${value}\n`;
}, "");
console.log(output);
@jwarby
Copy link
Author

jwarby commented Sep 23, 2021

Note: env vars are already sorted on the Netlify UI page so there is no need to implement sorting here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment