Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
timaschew opened this issue Dec 7, 2015 · 4 comments
Open

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

timaschew opened this issue Dec 7, 2015 · 4 comments

Comments

@timaschew
Copy link
Contributor

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')
@wires
Copy link
Owner

wires commented Dec 7, 2015

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

@timaschew
Copy link
Contributor Author

Your library is really great! Thank you for that.

@timaschew
Copy link
Contributor Author

any news?

@wires
Copy link
Owner

wires commented Feb 22, 2016

Hi, did some cleanup (94976ba) 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 💤

@wires wires added this to the v0.8.0 milestone Feb 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants