Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deduplicate active plugin list when using 'add' option #298

Merged
merged 2 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading