Skip to content

Commit

Permalink
fix: remove duplicate entries in PackageXml
Browse files Browse the repository at this point in the history
  • Loading branch information
amtrack committed Feb 12, 2024
1 parent 3891136 commit cde3468
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/package-xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class PackageXml {
.map((entry) => {
const [type, components] = entry;
return {
members: components.map((component) => component.fullName).sort(compareAlphanumeric),
members: [...new Set(components.map((component) => component.fullName).sort(compareAlphanumeric))],
name: type,
};
})
Expand Down
17 changes: 17 additions & 0 deletions test/package-xml.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ describe("PackageXml", () => {
fs.readFileSync(path.join(__dirname, "fixtures", "package", "package.json"), "utf8"),
);

describe("#toString()", () => {
it("removes duplicate entries", () => {
const pkg = new PackageXml([
{ type: "EmailTemplate", fullName: "unfiled$public" },
{ type: "EmailTemplate", fullName: "unfiled$public" },
]);
expect(pkg.toJSON()).to.deep.equal({
types: [
{
name: "EmailTemplate",
members: ["unfiled$public"],
},
],
});
});
});

describe("#toString()", () => {
it("should return the xml representation of a package", () => {
const expectedXml = fs.readFileSync(path.resolve(__dirname, "fixtures", "package", "package.xml")).toString();
Expand Down

0 comments on commit cde3468

Please sign in to comment.