Giter Club home page Giter Club logo

metalsmith-taxonomy's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mathiasprinz

metalsmith-taxonomy's Issues

Error on Windows because patterns depend on the underlying platform's path separator

Note: this is a minor issue (but I thought I'd file so others can search for and find the error message).

Repository to reproduce the error on Windows is here:
https://github.com/jaredkrinke/metalsmith-taxonomy-test

When building with Metalsmith on Windows, the native path separator is used to identify files in the files collection, e.g. "posts\test.md" (instead of "posts/test.md", as you'd see for POSIX). This probably breaks metalsmith-taxonomy when building on both platforms with identical code. The error is below, but it's basically saying "the matched file path isn't a key on files" (which is true because the path separators don't exactly match):

TypeError: Cannot read property 'category' of undefined
    at C:\Users\jared\Code\metalsmith-taxonomy-test\node_modules\metalsmith-taxonomy\lib\taxonomy-set.js:77:18
    at C:\Users\jared\Code\metalsmith-taxonomy-test\node_modules\metalsmith-taxonomy\lib\index.js:88:24
    at Array.forEach (<anonymous>)
    at C:\Users\jared\Code\metalsmith-taxonomy-test\node_modules\metalsmith-taxonomy\lib\index.js:85:27
    at Array.forEach (<anonymous>)
    at C:\Users\jared\Code\metalsmith-taxonomy-test\node_modules\metalsmith-taxonomy\lib\index.js:80:36
    at Array.forEach (<anonymous>)
    at Ware.plugin (C:\Users\jared\Code\metalsmith-taxonomy-test\node_modules\metalsmith-taxonomy\lib\index.js:67:18)
    at Ware.<anonymous> (C:\Users\jared\Code\metalsmith-taxonomy-test\node_modules\wrap-fn\index.js:45:19)
    at Immediate.next (C:\Users\jared\Code\metalsmith-taxonomy-test\node_modules\ware\lib\index.js:85:20)

In this case (repository linked above), I'm using the default options (so "/*.{md,html}") and I get the error above when building on Windows. If I change the pattern to "\*.{md,html}", then it builds fine on Windows. I suspect (but have not confirmed) that would then break on Linux.

Ideally, the same pattern (especially the default pattern) should work on any platform.

Fortunately, this issue is easily worked around by just adding another plugin to normalize slashes to "/".

For what it's worth, I'd argue that the multimatch behavior here is the correct behavior. It's debatable if a fix would be more appropriate in this plugin or Metalsmith itself, but I'd lean toward this plugin, since I haven't encountered this sort of problem with other plugins I've used (e.g. the "root path" plugin handles Windows fine).

And one last note: thanks for sharing this plugin! I had a custom plugin to do something similar, but this is a much more general design (and it includes some features I hadn't thought of). Nice work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.