Browse Source

send error back in callback

dev/fix.absolute.path
Brett Langdon 12 years ago
parent
commit
2bd59c30fe
2 changed files with 7 additions and 3 deletions
  1. +5
    -1
      bin/jsnice
  2. +2
    -2
      lib/index.js

+ 5
- 1
bin/jsnice View File

@ -23,6 +23,10 @@ var cwd = process.cwd();
filePath = path.join(cwd, args['<file>']); filePath = path.join(cwd, args['<file>']);
var js = fs.readFileSync(filePath); 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); console.log(data.js);
}); });

+ 2
- 2
lib/index.js View File

@ -22,12 +22,12 @@ module.exports.nicify = function(js, options, callback) {
res.on('end', function() { res.on('end', function() {
data = JSON.parse(data); data = JSON.parse(data);
callback(data);
callback(null, data);
}); });
}); });
req.on('error', function(err) { req.on('error', function(err) {
console.dir(err);
callback(err, null);
}); });
req.write(js); req.write(js);


Loading…
Cancel
Save