-
-
Save first-developer/b48e524023403c1ab2e6 to your computer and use it in GitHub Desktop.
hologam gulp plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
// 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