Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions e2e/global-teardown.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { execSync } from 'child_process';
import { execFileSync } from 'child_process';

const BACKEND_PORT = process.env.BACKEND_PORT || '5543';

Expand All @@ -13,11 +13,15 @@ const BACKEND_PORT = process.env.BACKEND_PORT || '5543';
* A single pkill pattern matches both.
*/
async function globalTeardown() {
if (!/^\d{2,5}$/.test(BACKEND_PORT)) {
return;
}

const pattern = `e2e:${BACKEND_PORT}`;
try {
const pids = execSync(`pgrep -f '${pattern}'`, { encoding: 'utf8' }).trim();
const pids = execFileSync('pgrep', ['-f', pattern], { encoding: 'utf8' }).trim();
if (pids) {
execSync(`pkill -f '${pattern}'`);
execFileSync('pkill', ['-f', pattern]);
console.log(` Stopped e2e test servers (session ${BACKEND_PORT}).`);
}
} catch {
Expand Down