Skip to content

Commit

Permalink
refactor: test for package version as well (#1146)
Browse files Browse the repository at this point in the history
additionally to the name check to determine whether this is an actual package file
  • Loading branch information
mfranzke committed Jun 12, 2022
1 parent 017400d commit 637b0fe
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/license-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ class LicensePlugin {
const license = pkgJson.license || pkgJson.licenses;
const hasLicense = license && license.length > 0;
const name = pkgJson.name;
const version = pkgJson.version;
const isValidPackageName = name && packageNameRegex.test(name);
if (isValidPackageName || hasLicense) {
if ((isValidPackageName && version) || hasLicense) {
// We found it!
pkg = pkgJson;

Expand Down

0 comments on commit 637b0fe

Please sign in to comment.