Skip to content

Instantly share code, notes, and snippets.

@evilUrge
Created September 1, 2020 09:53
Show Gist options
  • Save evilUrge/20a9ee14f6a1c06859e5ab69d632e825 to your computer and use it in GitHub Desktop.
Save evilUrge/20a9ee14f6a1c06859e5ab69d632e825 to your computer and use it in GitHub Desktop.
Fetch firebase remote config - a script for npm build
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