diff --git a/bin/jsnice b/bin/jsnice index 80f2b91..7ac1a86 100755 --- a/bin/jsnice +++ b/bin/jsnice @@ -23,6 +23,10 @@ var cwd = process.cwd(); filePath = path.join(cwd, args['']); var js = fs.readFileSync(filePath); -jsnice.nicify(js, function(data) { +jsnice.nicify(js, function(err, data) { + if (err) { + console.error(err); + process.exit(1); + } console.log(data.js); }); diff --git a/lib/index.js b/lib/index.js index 6323597..4531cdd 100644 --- a/lib/index.js +++ b/lib/index.js @@ -22,12 +22,12 @@ module.exports.nicify = function(js, options, callback) { res.on('end', function() { data = JSON.parse(data); - callback(data); + callback(null, data); }); }); req.on('error', function(err) { - console.dir(err); + callback(err, null); }); req.write(js);