Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
fix(logger/define-package): throw error if duplicate_package_defined (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
njfamirm authored Dec 11, 2023
2 parents 932c439 + c32be46 commit c0bbbf9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/logger/src/define-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@ export const definePackage = (packageName: string, version: string) => {
logger.logMethodArgs?.('define-package', {packageName, version});

if (packageName in Alwatr.packages) {
logger.accident?.('define-package', 'duplicate_package_defined', {
logger.error('define-package', 'duplicate_package_defined', {
packageName,
new: version,
old: Alwatr.packages[packageName],
});
return;
throw new Error('duplicate_package_defined');
}

if (packageName.indexOf('@alwatr') === -1) {
logger.error('define-package', 'package_name_starts_with_alwatr_scope', {
packageName,
});
throw new Error('package_name_starts_with_alwatr_scope');
}

Alwatr.packages[packageName] = version;
Expand Down

0 comments on commit c0bbbf9

Please sign in to comment.