Skip to content

Instantly share code, notes, and snippets.

@jchild3rs
Last active April 8, 2020 15:54
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jchild3rs/470be49a4bc4caf3ca8a to your computer and use it in GitHub Desktop.
Save jchild3rs/470be49a4bc4caf3ca8a to your computer and use it in GitHub Desktop.
Hologram 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