This commit is contained in:
Jason Ross
2026-03-31 20:34:43 -05:00
parent efa8990c0d
commit 350e43bbfb
2 changed files with 52 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
import path from "node:path";
const repoRoot = process.cwd();
const quote = (value) => JSON.stringify(value);
const inWorkspace = (workspace, file) => {
const relativePath = path.relative(repoRoot, file);
return (
relativePath === workspace ||
relativePath.startsWith(`${workspace}${path.sep}`)
);
};
const commandForWorkspace = (workspaceName, workspaceDir, files) => {
const workspaceFiles = files.filter(
(file) => inWorkspace(workspaceDir, file) && /\.(ts|tsx)$/.test(file)
);
if (workspaceFiles.length === 0) {
return null;
}
return `pnpm --filter ${workspaceName} exec eslint --fix ${workspaceFiles
.map(quote)
.join(" ")}`;
};
export default {
"**/*": (files) => {
const commands = [];
if (files.length > 0) {
commands.push(
`prettier --write --ignore-unknown ${files.map(quote).join(" ")}`
);
}
const apiCommand = commandForWorkspace("stoat-admin-api", "api", files);
if (apiCommand) {
commands.push(apiCommand);
}
const webCommand = commandForWorkspace("stoat-admin-web", "web", files);
if (webCommand) {
commands.push(webCommand);
}
return commands;
}
};
+1
View File
@@ -1,6 +1,7 @@
{
"name": "stoat-admin",
"private": true,
"type": "module",
"packageManager": "pnpm@10.6.3",
"license": "AGPL-3.0-only",
"devDependencies": {