/
githubmirror
/
pixijs
Обзор
Документация
Войти
/
githubmirror
/
pixijs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
scripts/jest/jest-global-setup.ts
42 строки
1 KB
Zyie
chore: Improve test server setup by dynamically allocating port (#11874)
04 фев 2026, 17:13
Не верифицирован
04 фев 2026, 17:13
a83d2bb
Код
Авторство
О чём код?
import { spawn } from 'child_process'; import { join } from 'path'; // eslint-disable-next-line func-names module.exports = async function () { if (!process.env.GITHUB_ACTIONS) { const { default: getPort } = await import('get-port'); const port = await getPort(); process.env.SERVER_PORT = String(port); const httpServerProcess = spawn( 'http-server', ['-c-1', '-p', String(port), `${join(process.cwd(), './')}`], { // See https://nodejs.org/api/child_process.html#spawning-bat-and-cmd-files-on-windows shell: process.platform === 'win32', }, ); // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore globalThis.__SERVER__ = httpServerProcess; // give the server time to start await new Promise<void>((resolve) => { let data = ''; httpServerProcess.stdout.on('data', (chunk) => { data += chunk; if (data.includes('Hit CTRL-C to stop the server')) { resolve(); } }); }); } };