Skip to content

Commit

Permalink
Fixes #2754
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Mar 22, 2023
1 parent 30c7113 commit 67ce615
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/EleventyTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -709,3 +709,13 @@ test("this.eleventy on JavaScript template functions, issue #2790", async (t) =>
t.deepEqual(result.length, 1);
t.deepEqual(result[0].content, `<p>Eleventy</p>`);
});

test("Global data JS files should only execute once, issue #2753", async (t) => {
let elev = new Eleventy("./test/stubs-2753", "./test/stubs-2753/_site", {
config: function (eleventyConfig) {},
});
let result = await elev.toJSON();
t.deepEqual(result.length, 2);
t.deepEqual(result[0].content, `1`);
t.deepEqual(result[0].content, `1`);
});
4 changes: 4 additions & 0 deletions test/stubs-2753/_data/global.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
let count = 0;
module.exports = async function () {
return ++count;
};
1 change: 1 addition & 0 deletions test/stubs-2753/page1.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ global }}
1 change: 1 addition & 0 deletions test/stubs-2753/page2.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ global }}

0 comments on commit 67ce615

Please sign in to comment.