Skip to content

Instantly share code, notes, and snippets.

@shavidzet
Last active December 9, 2019 16:40
Show Gist options
  • Save shavidzet/2dca3e3857ce71214f71e57e27f03eab to your computer and use it in GitHub Desktop.
Save shavidzet/2dca3e3857ce71214f71e57e27f03eab to your computer and use it in GitHub Desktop.
Export netlify environment variables as regular array of objects
/*
1. open url: https://app.netlify.com/sites/{projec_name}/settings/deploys#environment
2. click on edit variables
3. run following code
*/
const envs = [...$0.querySelectorAll('input')].reduce((state, i, k) => {
if ((k % 2 !== 0 || k === 0) && $0.querySelectorAll('input').length - 1 !== k) {
return state
} else if ($0.querySelectorAll('input').length - 1 === k) {
return [
...state,
`${$0.querySelectorAll('input')[k-1].value} - ${$0.querySelectorAll('input')[k].value}`
]
}
return [
...state,
`${$0.querySelectorAll('input')[k - 2].value} - ${$0.querySelectorAll('input')[k-1].value}`
]
}, [])
console.log(envs) // or copy(envs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment