UNPKG

pp-parachute

Version:
25 lines (24 loc) 797 B
var Promise = require('bluebird'); var fs = require('fs'); var Haml = require('haml-coffee'); module.exports = function (file) { return new Promise(function (resolve, reject) { fs.readFile(file, "utf-8", function (error, contents) { if (error) return reject(error); try { var html = Haml.render(contents, {uglify: true}); resolve({ path: file, html: html }); } catch (e) { return reject({ path: file, error: e.toString(), line: e.location && e.location.first_line, col: e.location && e.location.first_column }); } }); }); };