Skip to content

Commit

Permalink
refactor: small simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
mjeanroy committed Sep 3, 2023
1 parent 3afa9ac commit 40f758d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/license-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,16 @@ class LicensePlugin {
* @return {void}
*/
addDependency(pkg) {
const name = (this._options.thirdParty && this._options.thirdParty.multipleVersions) ?
`${pkg.name}@${pkg.version}` :
pkg.name;
const name = pkg.name || '';
if (!name) {
this.warn('Trying to add dependency without any name, skipping it.');
} else if (!_.has(this._dependencies, name)) {
this._dependencies[name] = new Dependency(pkg);
return;
}

const version = pkg.version || '';
const key = this._options.thirdParty?.multipleVersions ? `${name}@${version}` : name;
if (!_.has(this._dependencies, key)) {
this._dependencies[key] = new Dependency(pkg);
}
}

Expand Down

0 comments on commit 40f758d

Please sign in to comment.