mirror of
https://github.com/denoland/std.git
synced 2024-11-22 04:59:05 +00:00
46 lines
1.1 KiB
TypeScript
Executable File
46 lines
1.1 KiB
TypeScript
Executable File
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
|
import { walk } from "../fs/walk.ts";
|
|
|
|
const EXTENSIONS = [".mjs", ".js", ".ts", ".rs"];
|
|
const EXCLUDED_DIRS = [
|
|
"node/_module",
|
|
"node/_tools/test",
|
|
"node/_tools/versions",
|
|
"dotenv/testdata",
|
|
"fs/testdata",
|
|
"http/testdata",
|
|
"node/testdata",
|
|
"crypto/_wasm_crypto/target",
|
|
"encoding/varint/_wasm/target",
|
|
"_tools/testdata",
|
|
];
|
|
|
|
const ROOT = new URL("../", import.meta.url);
|
|
const FIRST_YEAR = 2018;
|
|
const CURRENT_YEAR = new Date().getFullYear();
|
|
const COPYRIGHT =
|
|
`// Copyright ${FIRST_YEAR}-${CURRENT_YEAR} the Deno authors. All rights reserved. MIT license.`;
|
|
|
|
let failed = false;
|
|
|
|
for await (
|
|
const { path } of walk(ROOT, {
|
|
exts: EXTENSIONS,
|
|
skip: EXCLUDED_DIRS.map((path) => new RegExp(path + "$")),
|
|
includeDirs: false,
|
|
})
|
|
) {
|
|
const content = await Deno.readTextFile(path);
|
|
if (!content.includes(COPYRIGHT)) {
|
|
console.error(`Missing/incorrect copyright header: ${path}`);
|
|
if (!failed) {
|
|
failed = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (failed) {
|
|
console.info(`Copyright header should be "${COPYRIGHT}"`);
|
|
Deno.exit(1);
|
|
}
|