Last active
December 9, 2019 16:40
-
-
Save shavidzet/2dca3e3857ce71214f71e57e27f03eab to your computer and use it in GitHub Desktop.
Export netlify environment variables as regular array of objects
This file contains hidden or 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
/* | |
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