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

Commit

Permalink
MINOR: Fix public license match RegExp
Browse files Browse the repository at this point in the history
Signed-off-by: German Zargaryan <[email protected]>
  • Loading branch information
germanz committed Jan 20, 2021
1 parent 5577854 commit 0c1142d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions scripts/checkLicenses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ function checkYear(
* IMPORTANT, RegExp match should match the whole license and in the match groups returns the
* following:
* - match[1] - copyright start year
* - match[3] - copyright end year (if specified)
* - match[2] - copyright end year (if specified)
* @param callback The callback function to execute upon completion. Array of errors strings is passed back,
* in case not matching file is found.
* @param [fix=false] Flag indicating whether correct licenses should be automatically fixed. Default is false.
*/
export function checkLicenses(
sourceFiles: string[],
Expand All @@ -100,7 +101,7 @@ export function checkLicenses(
errors.push(`${sourceFile} has no valid copyright notice`);
checkIfDone();
} else {
checkYear(sourceFile, [match[1], match[3]], error => {
checkYear(sourceFile, [match[1], match[2]], error => {
if (error) {
// Let's fix it in case of wrong year(s) found and AUTO_FIX is activated:
const errorMatch = /expected: (.+), found: (.+)/.exec(error);
Expand Down
2 changes: 1 addition & 1 deletion test/LicenseHeaderTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as path from "path";

import { checkLicenses } from "../scripts/checkLicenses";

const APACHE_LICENSE = /\/\*\n \* Copyright \(C\) (\d{4})(-(\d{4}))? HERE Europe B\.V\.\n \* Licensed under Apache 2\.0\, see full license in LICENSE\n \* SPDX\-License\-Identifier\: Apache\-2\.0\n \*\//;
const APACHE_LICENSE = /\/\*\n \* Copyright \(C\) (\d{4})(?:-(\d{4}))? HERE Europe B\.V\.\n \* Licensed under Apache 2\.0\, see full license in LICENSE\n \* SPDX\-License\-Identifier\: Apache\-2\.0\n \*\//;
// To fix wrong year(s) of the copyright notice on a local machine automatically:
const AUTO_FIX = process.argv.slice(2).includes("--fix");

Expand Down

0 comments on commit 0c1142d

Please sign in to comment.