Created
July 2, 2013 10:21
-
-
Save pyykkis/5908214 to your computer and use it in GitHub Desktop.
How james.js error handling should be done?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// james-coffee/index.js | |
var james = require('james'), | |
coffee = require('coffee-script'); | |
coffee.createStream = function() { | |
return james.createTransformation(function(content, callback) { | |
// Process the file content and call the callback with the result. | |
try { | |
res = coffee.compile(content); | |
callback(null, res); | |
} catch(err) { | |
callback(err, null); | |
} | |
}); | |
}; | |
james.read('./hello.coffee') | |
.transform(coffee.createStream) | |
.write(process.stdout); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment