From fe2e17990a1107054b6f4dd5300222766a716e6e Mon Sep 17 00:00:00 2001 From: Ruben Vermeersch Date: Tue, 17 Dec 2013 14:30:07 +0100 Subject: [PATCH] Fix the async calls. This is a breaking change. But that's okay, the previous behavior for async was just plain wrong and would crash the entire node process, which is unacceptable. A major version bump will be needed to release this. --- lib/po.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/po.js b/lib/po.js index 4a7d733..6bf1bf3 100644 --- a/lib/po.js +++ b/lib/po.js @@ -12,15 +12,7 @@ var PO = function () { }; PO.prototype.save = function (filename, callback) { - fs.writeFile(filename, this.toString(), function (err) { - if (err) { - throw err; - } - - if (callback) { - callback(); - } - }); + fs.writeFile(filename, this.toString(), callback); }; PO.prototype.toString = function () { @@ -54,10 +46,10 @@ PO.prototype.toString = function () { PO.load = function (filename, callback) { fs.readFile(filename, 'utf-8', function (err, data) { if (err) { - throw err; + return callback(err); } var po = PO.parse(data); - callback(po); + callback(null, po); }); };