metalsmith / layouts

A metalsmith plugin for layouts
MIT License
116 stars 49 forks source link

Fixes "too many opened files" error #120

Closed bbor closed 7 years ago

bbor commented 7 years ago

See issue #119. With this PR, we first compile a list of all the layout templates that our input files need. We then do a first pass of renders that treats one input file for each of these templates, so that consolidate will load all the templates into its cache. Then, once the templates are all cached, we run through the rest of the input files.

bbor commented 7 years ago

Hey, are there any maintainers around to take a look at this pull request?

ismay commented 7 years ago

Hey @bbor, I'll take a look at it this weekend. Been a bit busy.

ismay commented 7 years ago

So the code looks good, but I'm wondering, were you able to verify that this indeed works as intended (i.e. it's not loading any templates more than once)? Would be good if we could test it.

bbor commented 7 years ago

Since the loading is done inside Consolidate, the only way I had found to test the order of the load operations was to drop console.log statements inside Consolidate each time a template file load started and each time a load finished. Before the change, it would spam "start" events until it hit the too many files error. After the change, it would print "start-finished" pairs for each input template.

ismay commented 7 years ago

Hmm yeah. I'm tempted to merge it since we want to move to a different engine anyway for the next major release.

@doodzik What do you think?

doodzik commented 7 years ago

@ismay I'm in favour of this pr 👍

ismay commented 7 years ago

Cool, I'll merge asap

ismay commented 7 years ago

Released as 1.8.1