forked from clerk/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclerkJsServer.ts
More file actions
34 lines (27 loc) · 1.01 KB
/
Copy pathclerkJsServer.ts
File metadata and controls
34 lines (27 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* eslint-disable turbo/no-undeclared-env-vars */
import path from 'node:path';
import { stateFile } from '../models/stateFile';
import { getTempDir, killHttpServer, startHttpServer } from './httpServer';
export const startClerkJsHttpServer = async (): Promise<void> => {
if (process.env.E2E_APP_CLERK_JS) {
return;
}
const clerkJsTempDir = getTempDir('clerk-js/node_modules/@clerk/clerk-js/dist', 'E2E_APP_CLERK_JS_DIR');
const sourceDir = path.join(process.cwd(), 'packages/clerk-js/dist');
const { pid } = await startHttpServer({
name: 'clerkJs',
port: 18211,
sourceDir,
targetTempDir: clerkJsTempDir,
envVarOverride: 'E2E_APP_CLERK_JS',
envVarDirOverride: 'E2E_APP_CLERK_JS_DIR',
shouldCopyInLocal: true,
});
stateFile.setClerkJsHttpServerPid(pid);
};
export const killClerkJsHttpServer = async (): Promise<void> => {
const clerkJsHttpServerPid = stateFile.getClerkJsHttpServerPid();
if (clerkJsHttpServerPid) {
await killHttpServer(clerkJsHttpServerPid, 'clerkJs');
}
};