UNPKG

gulp-livingstyleguide

Version:

Easily create living styleguides with Markdownn and Sass/Scss using the livingstyleguide gem

61 lines (53 loc) 1.79 kB
// Generated by CoffeeScript 1.10.0 (function() { 'use strict'; var PLUGIN_NAME, exec, fs, gutil, through; PLUGIN_NAME = 'gulp-livingstyleguide'; fs = require('fs'); exec = require('child_process').exec; gutil = require('gulp-util'); through = require('through2'); module.exports = function(options) { var flush, transform; if (options == null) { options = {}; } transform = function(file, enc, callback) { var error; if (file.isStream()) { error = new gutil.PluginError(PLUGIN_NAME, 'Streaming not supported'); this.emit('error', error); return callback(); } return exec("bundle exec livingstyleguide compile " + file.path, (function(_this) { return function(error) { var err, error1, styleguide, styleguideFilePath, styleguideHtmlFilePath; if (error) { error = new gutil.PluginError(PLUGIN_NAME, error); _this.emit('error', error); return callback(); } styleguideFilePath = file.path.replace(/\..*$/g, ''); styleguideHtmlFilePath = styleguideFilePath + ".html"; file.path = styleguideHtmlFilePath; styleguide = fs.readFileSync(styleguideHtmlFilePath); fs.unlink(styleguideHtmlFilePath); try { file.contents = new Buffer(styleguide); } catch (error1) { error = error1; err = new gutil.PluginError(PLUGIN_NAME, error); _this.emit('error', err); return callback(); } _this.push(file); return callback(); }; })(this)); }; flush = function(callback) { return callback(); }; return through.obj(transform, flush); }; }).call(this);