Created
September 23, 2017 18:30
-
-
Save ThadeuLuz/943993bf80781d520dae4d864396ed3e to your computer and use it in GitHub Desktop.
Simple Firebase and cli integration
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
// 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