Skip to content

Instantly share code, notes, and snippets.

@ThadeuLuz
Created September 23, 2017 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThadeuLuz/943993bf80781d520dae4d864396ed3e to your computer and use it in GitHub Desktop.
Save ThadeuLuz/943993bf80781d520dae4d864396ed3e to your computer and use it in GitHub Desktop.
Simple Firebase and cli integration
// Lembre de rodar: npm i firebase
const firebase = require("firebase");
const exec = require("child_process").exec;
var config = {
// Sua configuração do firebase
};
const firebaseApp = firebase.initializeApp(config);
const ref = firebaseApp.database().ref();
firebaseApp.auth().onAuthStateChanged(user => {
console.log("Firebase inicializado!");
// Lembre de permitir leitura nas regras
ref.on("value", snap => {
const command = "echo " + snap.val();
// Roda comando no terminal
exec(command, (_err, stdout, stderr) => {
console("Done!");
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment