Skip to content

Commit

Permalink
Merge pull request #298 from gfscott/everything-config
Browse files Browse the repository at this point in the history
Deduplicate active plugin list when using 'add' option
  • Loading branch information
gfscott authored Dec 8, 2024
2 parents 874b0e5 + 1fd1ba8 commit 66e4db6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/green-cameras-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eleventy-plugin-embed-everything": patch
---

Deduplicate list of active plugins when using the 'add' option
3 changes: 2 additions & 1 deletion packages/everything/lib/configOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ module.exports = function(options = {}) {
function setActivePlugins(obj) {
let active = [...defaultPlugins]; // default
// Add to default plugin list
// The `Set` ensures there are no duplicates
if (obj.add) {
active = [...defaultPlugins, ...obj.add];
active = [...new Set([...defaultPlugins, ...obj.add])];
}
// Define custom plugin list from scratch.
// Will always override `add`
Expand Down
11 changes: 11 additions & 0 deletions packages/everything/test/test-configOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ test(
},
);

test(
`Config "add" option returns deduplicated output when adding plugins already included by default`,
(t) => {
let output = config({
// These are already active by default, so `add`ing should do nothing
add: ["youtube", "vimeo"],
});
t.deepEqual(output, defaultOptions);
},
)

test(
`Config returns expected output with valid "use" option`,
(t) => {
Expand Down

0 comments on commit 66e4db6

Please sign in to comment.