70bf21e064
Deploy (to testing) and Test Playground Preview Worker / Deploy Playground Preview Worker (testing) (push) Has been skipped
Deploy Workers Shared Staging / Deploy Workers Shared Staging (push) Failing after 0s
Prerelease / build (push) Has been skipped
Handle Changesets / Handle Changesets (push) Has been cancelled
Semgrep OSS scan / semgrep-oss (push) Has been cancelled
28 lines
773 B
TypeScript
28 lines
773 B
TypeScript
import { spawn } from "node:child_process";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import * as find from "empathic/find";
|
|
|
|
const currentFile = process.argv[2];
|
|
const currentDirectory = path.dirname(currentFile);
|
|
|
|
const packageJsonPath = find.file("package.json", { cwd: currentDirectory });
|
|
|
|
if (!packageJsonPath) {
|
|
console.error("No package.json found.");
|
|
process.exit(1);
|
|
}
|
|
|
|
const packageJsonContent = fs.readFileSync(packageJsonPath, "utf8");
|
|
const packageJson = JSON.parse(packageJsonContent);
|
|
const packageName = packageJson.name;
|
|
|
|
const command = `pnpm`;
|
|
const args = ["test", "-F", packageName, "--", currentFile];
|
|
|
|
const testProcess = spawn(command, args, { stdio: "inherit" });
|
|
|
|
testProcess.on("close", (code) => {
|
|
process.exit(code ?? 1);
|
|
});
|