Last active
July 20, 2019 15:48
-
-
Save vinothpandian/64ded312420a534fcba52f38c072c5fc to your computer and use it in GitHub Desktop.
Convert firebaseConfig to .env
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
const firebaseConfigMap = { | |
apiKey: "REACT_APP_APIKEY", | |
authDomain: "REACT_APP_AUTH_DOMAIN", | |
databaseURL: "REACT_APP_DATABASE_URL", | |
projectId: "REACT_APP_PROJECT_ID", | |
storageBucket: "REACT_APP_STORAGE_BUCKET", | |
messagingSenderId: "REACT_APP_MESSAGING_SENDER_ID", | |
appId: "REACT_APP_APP_ID" | |
}; | |
// const keyify = key => `REACT_APP_${key.split(/(/W)/)}` | |
const keyify = key => `REACT_APP_${key.replace(/\.?([A-Z]+)/g, (x,y) => `_${y}`).toUpperCase()}` | |
const envData = Object.keys(firebaseConfig).reduce((prev, key) => ({ | |
...prev, | |
[keyify(key)]: firebaseConfig[key] | |
}), {}) | |
Object.entries(envData).forEach(([key, value]) => { | |
console.log(`${key}=${value}`) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment