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

Commit

Permalink
fix(logger): duplicate package definition and throw error
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd committed Dec 19, 2023
1 parent 08679e9 commit 640ce6a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/logger/src/define-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ const logger = createLogger('logger');
setTimeout(() => {
if ('registeredList' in Alwatr) {
logger.accident?.('define-package', 'duplicate_old_package_defined', Alwatr.registeredList);
throw new Error('duplicate_old_package_defined');
}
}, 2000);

export const definePackage = (packageName: string, version: string) => {
logger.logMethodArgs?.('define-package', {packageName, version});

if (packageName in Alwatr.packages) {
logger.error('define-package', 'duplicate_package_defined', {
logger.accident('define-package', 'duplicate_package_defined', {
packageName,
new: version,
old: Alwatr.packages[packageName],
Expand All @@ -24,7 +25,7 @@ export const definePackage = (packageName: string, version: string) => {
}

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

0 comments on commit 640ce6a

Please sign in to comment.