Skip to content

Instantly share code, notes, and snippets.

@mpangrazzi
Last active August 29, 2015 14:10
Show Gist options
  • Save mpangrazzi/aff33f81607bdb4141f6 to your computer and use it in GitHub Desktop.
Save mpangrazzi/aff33f81607bdb4141f6 to your computer and use it in GitHub Desktop.
Wrap less.render() in a Promise for using with `co` or directly
/**
* Module dependencies
*/
var less = require('less');
// wrap less.render() in a native Promise
module.exports = function(code, options) {
return new Promise(function(resolve, reject) {
less.render(code, options, function(err, output) {
if (err) return reject(err);
resolve(output.css);
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment