patrickarlt / acetate

A flexible, fast and easy to extend static site generator for Node
http://acetate.io
ISC License
20 stars 13 forks source link

Page transforming does not work when symlinking a directory #69

Closed noahmulfinger closed 7 years ago

noahmulfinger commented 7 years ago

Here is an example of a failing test (added a metadata command to the current symlink test):

test("should set metadata of symlinked files", t => {
  const acetate = new Acetate({
    root: t.context.temp,
    sourceDir: "loader-basic",
    log: "silent",
    config: false
  });

  acetate.load("**/*.+(md|html)");

  acetate.metadata("external/**/*", {
    title: "Template"
  });

  acetate.symlink("create-page", "external");

  return acetate.getPages().then(pages => {
    const page = pages.find(page => page.src === "external/page.html");
    t.is(page.src, "external/page.html");
    t.is(page.title, "Template");
  });
});

These additional modifications to the test had no effect:

patrickarlt commented 7 years ago

@noahmulfinger in your test the transforms aren't being run, this test passes:

test.only("should set metadata of symlinked files", t => {
  const acetate = new Acetate({
    root: t.context.temp,
    sourceDir: "loader-basic",
    log: "silent",
    config: false
  });

  acetate.load("**/*.+(md|html)");

  acetate.symlink("create-page", "external");

  acetate.metadata("external/**/*", {
    title: "Template"
  });

  return acetate
    .getPages()
    .then(pages => {
      return Promise.all(pages.map(p => acetate.transformPage(p)));
    })
    .then(transformedPages => {
      const page = transformedPages.find(
        page => page.src === "external/page.html"
      );
      t.is(page.src, "external/page.html");
      t.is(page.title, "Template");
    });
});

Could you double check the paths that you are passing to acetate.symlink()? Maybe a path is wrong.

noahmulfinger commented 7 years ago

@patrickarlt You're right, the paths were wrong. I didn't realize that the src argument was from the project root, but the dest argument was from the src directory. Closing.