Skip to content

Commit

Permalink
refactor(dedupe): prevent throw error on duplicate package and just l…
Browse files Browse the repository at this point in the history
…og it
  • Loading branch information
alimd committed Aug 31, 2024
1 parent 5d81b77 commit 9d2b657
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/dedupe/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@ export const definedPackageList: Dictionary<string> = {};
* ```
*/
export function definePackage(packageName: string, version = 'v?'): void {
if (packageName in definedPackageList) {
throw new Error('duplicate_package', {
cause: packageName,
});
if (Object.prototype.hasOwnProperty.call(definedPackageList, packageName)) {
console.error(
new Error('duplicate_package', {
cause: {
packageName,
newVersion: version,
oldVersion: definedPackageList[packageName],
},
}),
);
}

definedPackageList[packageName] = version;
Expand Down

0 comments on commit 9d2b657

Please sign in to comment.