gulp-static-site icon indicating copy to clipboard operation
gulp-static-site copied to clipboard

plugin doesn't work if you're not working in the root

Open timaschew opened this issue 9 years ago • 4 comments

I have all my files in a src directory. So I start it with this lines:

gulp.task('site', function () {
    gulp.src('src/contents/**/*.md')
        .pipe(static_site())
        .pipe(gulp.dest('build/'))
});

But the problem occurs when your plugin tries to load the template which is assumed to be located always in the (gulp) root directory? https://github.com/wires/gulp-static-site/blob/master/index.js#L90

I tried to change the exporting module, add an options argument:

var options =  {}
module.exports = function(opts) {
    options = opts;
    .pipe($.marked)
    lazypipe()
    .pipe($.map, extended_attributes)
    .pipe($.marked)
////    .pipe(resolve_wiki_links)
    .pipe($.filetree)
    .pipe(show_tree_once)
    .pipe(render_tmpl)
    .pipe($.size)

but even If I bind the context of lazypipe to the outer scope, it doesn't work, I get this error:

[10:13:25] 'site' errored after 12 ms
[10:13:25] TypeError: Cannot read property 'on' of undefined
    at DestroyableTransform.Readable.pipe (/Users/awilhelm/dev/musik-kuntschule/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:516:7)
    at Gulp.<anonymous> (/Users/awilhelm/dev/musik-kuntschule/gulp/index.js:41:10)
    at module.exports (/Users/awilhelm/dev/musik-kuntschule/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/Users/awilhelm/dev/musik-kuntschule/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/Users/awilhelm/dev/musik-kuntschule/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/Users/awilhelm/dev/musik-kuntschule/node_modules/orchestrator/index.js:134:8)
    at runNextSet (/Users/awilhelm/dev/musik-kuntschule/node_modules/run-sequence/index.js:88:16)
    at runSequence (/Users/awilhelm/dev/musik-kuntschule/node_modules/run-sequence/index.js:99:2)
    at Gulp.<anonymous> (/Users/awilhelm/dev/musik-kuntschule/gulp/index.js:15:2)
    at module.exports (/Users/awilhelm/dev/musik-kuntschule/node_modules/orchestrator/lib/runTask.js:34:7)
[10:13:25] 'dev' errored after 18 ms

So for now I fixed it via a hardcoded line:

        //TODO: how to make this configurable?
        var baseDir = 'src/'
        return compile_template(baseDir + 'templates/' + t + '.jade')

timaschew avatar Dec 07 '15 09:12 timaschew

Hi, thanks for your report. I will look into to this, this plugin needs some love :-)

wires avatar Dec 07 '15 16:12 wires

Your library is really great! Thank you for that.

timaschew avatar Dec 07 '15 22:12 timaschew

any news?

timaschew avatar Jan 18 '16 16:01 timaschew

Hi, did some cleanup (94976baffaabf6fd2b2f2b85eefbed7124354a45) but more work needed to brush this thing up. Updated the example (https://github.com/wires/gulp-static-site-example) so I can test this again. See what the problem is, will fix this week, now :zzz:

wires avatar Feb 22 '16 04:02 wires