I'm trying to console log whether or not my function is running successfully, or it encounters an error.
var gui = require('nw.gui');
var fs = require('fs');
onload = function() {
//console.log(gui.App.argv);
console.log("onload() is running - from <saveFile.js>")
var outputPath = gui.App.dataPath + "\\saves\\" + "content.txt";
var content = "hello world";
fs.writeFileSync(outputPath, JSON.stringify(content), "utf8", function(err) {
if(err) {
console.log(err);
}
else{
console.log('saved in ' + outputPath);
}
});
};
it logs the error if encountered, but the else statement never executes.
Aucun commentaire:
Enregistrer un commentaire