Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env node
|
||||
const { spawn } = require("node:child_process");
|
||||
const { existsSync, readdirSync, statSync } = require("node:fs");
|
||||
const { dirname, extname, join, relative, resolve } = require("node:path");
|
||||
|
||||
const repoRoot = process.env.TOOLCTRL_REPO_ROOT || resolve(dirname(__filename), process.env.ESLINT_PNPM_EXEC_REPO_ROOT_OFFSET ?? "../..");
|
||||
const eslintEntry = resolve(dirname(require.resolve("eslint/package.json", { paths: [repoRoot] })), "bin/eslint.js");
|
||||
const lintableExtensions = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"]);
|
||||
|
||||
function expandDirectoryArgument(argument) {
|
||||
const absolute = resolve(repoRoot, argument);
|
||||
if (!existsSync(absolute) || !statSync(absolute).isDirectory()) return [argument];
|
||||
|
||||
const files = readdirSync(absolute)
|
||||
.map((entry) => join(absolute, entry))
|
||||
.filter((entry) => statSync(entry).isFile() && lintableExtensions.has(extname(entry)))
|
||||
.map((entry) => relative(repoRoot, entry));
|
||||
|
||||
return files.length > 0 ? files : [argument];
|
||||
}
|
||||
|
||||
const args = process.argv.slice(2).flatMap(expandDirectoryArgument);
|
||||
const child = spawn(process.execPath, [eslintEntry, ...args], { cwd: repoRoot, stdio: "inherit" });
|
||||
|
||||
child.on("exit", (code, signal) => {
|
||||
if (signal) {
|
||||
process.kill(process.pid, signal);
|
||||
return;
|
||||
}
|
||||
|
||||
process.exit(code ?? 1);
|
||||
});
|
||||
Reference in new issue
Block a user