Created
September 1, 2020 09:53
-
-
Save evilUrge/20a9ee14f6a1c06859e5ab69d632e825 to your computer and use it in GitHub Desktop.
Fetch firebase remote config - a script for npm build
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
require('dotenv').config() | |
const admin = require("firebase-admin"); | |
admin.initializeApp({ | |
credential: admin.credential.cert( | |
process.env.NODE_ENV === 'production' | |
? require('./gcp.json') | |
: JSON.parse(process.env.FIREBASE_ADMIN_SDK) | |
), | |
databaseURL: process.env.FIREBASE_DATABASE_URL | |
}); | |
admin.remoteConfig().getTemplate() | |
.then(content => | |
require('fs').writeFile('remoteConfig.json', JSON.stringify(content.parameterGroups), 'utf8', | |
(err) => err | |
? console.error(`failed to write remote conf: ${err}`) | |
: process.exit() | |
)) | |
.catch(err => console.error(`failed fetching remote conf: ${err}`)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment