mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-06 15:15:47 +02:00
Merge pull request #20782 from nicolo-ribaudo/license-header-lint
Add script to check license headers
This commit is contained in:
commit
ece03f9960
79
gulpfile.mjs
79
gulpfile.mjs
@ -2041,6 +2041,82 @@ gulp.task(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
gulp.task("lint-licenses", function (done) {
|
||||||
|
console.log("\n### Checking license headers");
|
||||||
|
|
||||||
|
const jsRE =
|
||||||
|
/^(?:#[^\n]*\n)?\/\* Copyright \d{4} Mozilla Foundation\n \*\n \* Licensed under the Apache License, Version 2\.0 \(the "License"\);/;
|
||||||
|
const htmlRE = /^<!doctype html>\n<!--\nCopyright \d{4} Mozilla Foundation\n/;
|
||||||
|
|
||||||
|
// Files with non-standard license headers (different copyright holder,
|
||||||
|
// different license, or missing license).
|
||||||
|
const NON_STANDARD_HEADER_FILES = new Set([
|
||||||
|
"examples/learning/helloworld.html",
|
||||||
|
"examples/learning/helloworld64.html",
|
||||||
|
"examples/learning/prevnext.html",
|
||||||
|
"examples/node/getinfo.mjs",
|
||||||
|
"examples/text-only/index.html",
|
||||||
|
"examples/webpack/index.html",
|
||||||
|
"examples/webpack/main.mjs",
|
||||||
|
"examples/webpack/webpack.config.js",
|
||||||
|
"test/add_test.mjs",
|
||||||
|
"src/license_header_libre.js",
|
||||||
|
"src/shared/murmurhash3.js",
|
||||||
|
"test/font/font_core_spec.js",
|
||||||
|
"test/font/font_fpgm_spec.js",
|
||||||
|
"test/font/font_os2_spec.js",
|
||||||
|
"test/font/font_post_spec.js",
|
||||||
|
"test/reporter.js",
|
||||||
|
"test/resources/reftest-analyzer.css",
|
||||||
|
"test/resources/reftest-analyzer.js",
|
||||||
|
"test/stats/statcmp.js",
|
||||||
|
"web/grab_to_pan.js",
|
||||||
|
"web/toggle_button.css",
|
||||||
|
]);
|
||||||
|
|
||||||
|
const errors = [];
|
||||||
|
|
||||||
|
gulp
|
||||||
|
.src(
|
||||||
|
[
|
||||||
|
"{src,web,test,examples}/**/*.{js,mjs,css}",
|
||||||
|
"examples/**/*.html",
|
||||||
|
"!web/wasm/**/*",
|
||||||
|
],
|
||||||
|
{
|
||||||
|
base: ".",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.on("data", function (file) {
|
||||||
|
const relativePath = file.relative;
|
||||||
|
const content = file.contents.toString();
|
||||||
|
const re = relativePath.endsWith(".html") ? htmlRE : jsRE;
|
||||||
|
|
||||||
|
if (NON_STANDARD_HEADER_FILES.has(relativePath)) {
|
||||||
|
if (re.test(content)) {
|
||||||
|
console.warn(
|
||||||
|
` ${relativePath} has a standard license header, but is in the list of non-standard header files list.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!re.test(content)) {
|
||||||
|
errors.push(relativePath);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on("end", function () {
|
||||||
|
if (errors.length > 0) {
|
||||||
|
for (const file of errors.sort()) {
|
||||||
|
console.log(` Invalid license header: ${file}`);
|
||||||
|
}
|
||||||
|
done(new Error("License header check failed."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log("files checked, no errors found");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
gulp.task("lint", function (done) {
|
gulp.task("lint", function (done) {
|
||||||
console.log("\n### Linting JS/CSS/JSON/SVG/HTML files");
|
console.log("\n### Linting JS/CSS/JSON/SVG/HTML files");
|
||||||
|
|
||||||
@ -2111,8 +2187,7 @@ gulp.task("lint", function (done) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("files checked, no errors found");
|
gulp.task("lint-licenses")(done);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
/* Copyright 2014 Mozilla Foundation
|
/* Copyright 2014 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the 'License');
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an 'AS IS' BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* Copyright 2014 Mozilla Foundation
|
||||||
* Copyright 2014 Mozilla Foundation
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* Copyright 2013 Mozilla Foundation
|
||||||
* Copyright 2013 Mozilla Foundation
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* Copyright 2014 Mozilla Foundation
|
||||||
* Copyright 2014 Mozilla Foundation
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@ -1,3 +1,18 @@
|
|||||||
|
/* Copyright 2026 Mozilla Foundation
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
awaitPromise,
|
awaitPromise,
|
||||||
closePages,
|
closePages,
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* Copyright 2014 Mozilla Foundation
|
||||||
* Copyright 2014 Mozilla Foundation
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* Copyright 2014 Mozilla Foundation
|
||||||
* Copyright 2014 Mozilla Foundation
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* Copyright 2014 Mozilla Foundation
|
||||||
* Copyright 2014 Mozilla Foundation
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user