diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-01-13 13:42:15 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-13 13:42:15 -0500 |
commit | 3d423e114e46f206ad2c6bfa5dfcb22094c5d2f6 (patch) | |
tree | 2bc1e25c9703128cd0b0ceccea63f659750226f2 /tools/copyright_checker.js | |
parent | 377f59327344bbb4f37b2eec189ae981a9a9db45 (diff) |
chore: small cleanup of scripts in ./tools and run copyright checker in lint.js (#17393)
Diffstat (limited to 'tools/copyright_checker.js')
-rw-r--r-- | tools/copyright_checker.js | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/tools/copyright_checker.js b/tools/copyright_checker.js index 706f59dbd..c8ddcdc91 100644 --- a/tools/copyright_checker.js +++ b/tools/copyright_checker.js @@ -1,4 +1,4 @@ -#!/usr/bin/env -S deno run --unstable --allow-read --allow-run +#!/usr/bin/env -S deno run --unstable --allow-read=. --allow-run=git // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. import { getSources, ROOT_PATH } from "./util.js"; @@ -16,7 +16,7 @@ async function readFirstPartOfFile(filePath) { } } -async function checkCopyright() { +export async function checkCopyright() { const sourceFiles = await getSources(ROOT_PATH, [ // js and ts "*.js", @@ -28,7 +28,6 @@ async function checkCopyright() { ":!:cli/tsc/*typescript.js", ":!:cli/tsc/compiler.d.ts", ":!:test_util/wpt/**", - ":!:tools/**", // these files are starts with `#!/usr/bin/env` ":!:cli/tools/init/templates/**", // rust @@ -58,8 +57,9 @@ async function checkCopyright() { continue; } + // use .includes(...) because the first line might be a shebang if ( - !fileText.startsWith( + !fileText.includes( "// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.", ) ) { @@ -68,17 +68,11 @@ async function checkCopyright() { } } - console.log("\nTotal errors: " + totalCount); - if (totalCount > 0) { - Deno.exit(1); + throw new Error(`Copyright checker had ${totalCount} errors.`); } } -async function main() { - await Deno.chdir(ROOT_PATH); - +if (import.meta.main) { await checkCopyright(); } - -await main(); |