Skip to content

Instantly share code, notes, and snippets.

@first-developer
Forked from jchild3rs/gist:470be49a4bc4caf3ca8a
Last active August 29, 2015 14:19
Show Gist options
  • Save first-developer/b48e524023403c1ab2e6 to your computer and use it in GitHub Desktop.
Save first-developer/b48e524023403c1ab2e6 to your computer and use it in GitHub Desktop.
hologam gulp plugin
/*
// Usage:
gulp.task('docs', function(cb) {
gulp.src('path/to/your/src')
.pipe(hologram(cb));
});
*/
var gulp = require('gulp'),
notify = require('gulp-notify'),
gutil = require('gulp-util'),
map = require('map-stream'),
spawn = require('child_process').spawn;
/**
* Facade/Plugin for compiling Hologram as a stream
* @param task
* @param taskCallback
* @returns {*}
*/
module.exports = function(taskCallback) {
// (child-process.spawn implementation)
return map(function(file) {
var args = [
'./path-to-your-config-here.yml'
],
hologram = spawn('hologram', args, {stdio: 'inherit'});
hologram
// Print hologram stdout to log.
.on('data', function(data) {
gutil.log(data.toString().trim());
})
// Handle end of command execution.
.on('close', function(code) {
var error;
if (code && 0 !== code) {
error = new gutil.PluginError('hologram', 'Hologram failed with error code: ' + code);
}
taskCallback(error, file);
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment