chore: small cleanup of scripts in ./tools and run copyright checker in lint.js (#17393)

This commit is contained in:
David Sherret 2023-01-13 13:42:15 -05:00 committed by GitHub
parent 377f593273
commit 3d423e114e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 121 additions and 153 deletions

View file

@ -7,6 +7,28 @@ import {
join,
ROOT_PATH,
} from "./util.js";
import { checkCopyright } from "./copyright_checker.js";
let didLint = false;
if (Deno.args.includes("--js")) {
await dlint();
await dlintPreferPrimordials();
didLint = true;
}
if (Deno.args.includes("--rs")) {
await clippy();
didLint = true;
}
if (!didLint) {
await dlint();
await dlintPreferPrimordials();
console.log("copyright checker");
await checkCopyright();
await clippy();
}
async function dlint() {
const configFile = join(ROOT_PATH, ".dlint.json");
@ -44,6 +66,7 @@ async function dlint() {
const chunks = splitToChunks(sourceFiles, `${execPath} run`.length);
for (const chunk of chunks) {
const cmd = new Deno.Command(execPath, {
cwd: ROOT_PATH,
args: ["run", "--config=" + configFile, ...chunk],
stdout: "inherit",
stderr: "inherit",
@ -77,6 +100,7 @@ async function dlintPreferPrimordials() {
const chunks = splitToChunks(sourceFiles, `${execPath} run`.length);
for (const chunk of chunks) {
const cmd = new Deno.Command(execPath, {
cwd: ROOT_PATH,
args: ["run", "--rule", "prefer-primordials", ...chunk],
stdout: "inherit",
stderr: "inherit",
@ -116,6 +140,7 @@ async function clippy() {
}
const cargoCmd = new Deno.Command("cargo", {
cwd: ROOT_PATH,
args: [
...cmd,
"--",
@ -131,28 +156,3 @@ async function clippy() {
throw new Error("clippy failed");
}
}
async function main() {
await Deno.chdir(ROOT_PATH);
let didLint = false;
if (Deno.args.includes("--js")) {
await dlint();
await dlintPreferPrimordials();
didLint = true;
}
if (Deno.args.includes("--rs")) {
await clippy();
didLint = true;
}
if (!didLint) {
await dlint();
await dlintPreferPrimordials();
await clippy();
}
}
await main();