ozum / vuepress-bar

VuePress sidebar and navbar generator based on file and directory structure. Focus your documents, not sidebar or navbar.
90 stars 40 forks source link

fix error on folder without any md file #14

Closed nweldev closed 4 years ago

nweldev commented 4 years ago

if a directory only has subdirectories, a TypeError (link.children[0] || "").split is not a function was raised

ozum commented 4 years ago

Thanks, I'll update npm in a few minutes.

ozum commented 4 years ago

@noelmace, I had to reverse this commit, because it failed a test.

Could you please examine docs/example-missing-readme and related test. It passes when there is no md in folder.

Could you please create a new failing test for your case and create a PR solving it.

Thanks again.

nweldev commented 4 years ago

Hi ozum. If I understand correctly, you're talking about "should throw for missing README.md in Navbar", which was already failing before. I just ran npm run test on 611b4fb just to be sure : image Yet, this PR still introduced a regression, as it broke "sort file and folder by prefix" :

getConfig › sort file and folder by prefix

    expect(received).toEqual(expected) // deep equality

    - Expected
    + Received

    @@ -1,16 +1,16 @@
      Object {
        "nav": Array [],
        "sidebar": Array [
          "01-file",
    +     "03-file",
          Object {
            "children": Array [
              "02-folder/file",
            ],
            "title": "Folder",
          },
    -     "03-file",
          Object {
            "children": Array [
              "no-name/last",
            ],
            "title": "No Name",

      30 | 
      31 |   it("sort file and folder by prefix", async () => {
    > 32 |     expect(configOf("sort")).toEqual(expected("sort"));
         |                              ^
      33 |   });
      34 | });
      35 | 

      at Object.<anonymous> (lib/index.test.js:32:30)

My bad :sweat: I'm on it!

nweldev commented 4 years ago

done in #16