Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Package: Scripts: Use String#includes for improved code clarity
  • Loading branch information
aduth committed Sep 17, 2018
commit 2cc72cc6824056c37635de94b9260ebce4b46f7e
4 changes: 2 additions & 2 deletions packages/scripts/scripts/check-licenses.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const checkLicense = ( allowedLicense, licenseType ) => {
}

// We can skip the parsing below if there isn't an 'OR' in the license.
if ( licenseType.indexOf( 'OR' ) < 0 ) {
if ( ! licenseType.includes( 'OR' ) ) {
return false;
}

Expand Down Expand Up @@ -226,7 +226,7 @@ modules.forEach( ( path ) => {
let licenseType = typeof license === 'object' ? license.type : license;

// Check if the license we've detected is telling us to look in the license file, instead.
if ( licenseType && licenseFiles.find( ( licenseFile ) => licenseType.indexOf( licenseFile ) >= 0 ) ) {
if ( licenseType && licenseFiles.find( ( licenseFile ) => licenseType.includes( licenseFile ) ) ) {
licenseType = undefined;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the license property is pointing a file describing a truly incompatible license? Wouldn't this wrongly allow the license to be considered valid? I expect this to be even more common for non-standard licenses.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! I missed the code immediately following this, where we try to infer the license type from the presence of a file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙂

}

Expand Down