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

DRY up the gulpfile #16

Open
strugee opened this issue May 4, 2017 · 1 comment
Open

DRY up the gulpfile #16

strugee opened this issue May 4, 2017 · 1 comment

Comments

@strugee
Copy link
Member

strugee commented May 4, 2017

The gulpfile repeats a lot of stuff, unfortunately. I should think about ways to DRY that up.

@strugee
Copy link
Member Author

strugee commented May 8, 2017

So here's what I think about this. We want the following properties:

  1. Don't read in blog posts unless they're actually needed
  2. Have one single source of truth inside the gulpfile for the loading/parsing logic (stuff like frontmatter, dateInPath(), etc.)
  3. Only run that loading/parsing logic once at runtime, even if multiple tasks require it.

Probably the best way to do this is to define a function in the gulpfile that, on first run, constructs the read stream and assigns it to a variable. On every run (including the first) the "source" stream is forked with something like pipe-iterators' fork() and returned. That way each task gets its own stream that it can mess with in whatever way it wants.

Then gulp.src() through dateInPath() can be replaced with this function, and it'll work the same (i.e. have a .pipe() method) because the function just returns a stream, just like gulp.src.

@strugee strugee mentioned this issue Feb 9, 2018
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant