I'm trying to create a simple node.JS command-line script to interact with Firebase using their Javascript API. I want the tool to close the Firebase connection and terminate once it has finished it's interaction.
Here is some sample code showing what I am trying to achieve:
var Firebase = require('firebase');
var myRootRef = new Firebase('https://myprojectname.firebaseIO-demo.com/');
myRootRef.set('It's working!');
One possible solution would be adding a callback and calling process.exit():
var Firebase = require('firebase');
var myRootRef = new Firebase('https://myprojectname.firebaseIO-demo.com/');
myRootRef.set("It's working!", function() {
process.exit(0);
});
However, I would love to have a more elegant solution than forcing the process to terminate with process.exit().
Any ideas?