2023-02-14 20:45:31 +01:00

16 lines
594 B
TypeScript

import {ChildProcessWithoutNullStreams, spawn} from "child_process";
import path from "path";
export const wait = (ms: number): Promise<void> => new Promise(resolve => setTimeout(resolve, ms));
export const startServer = (params: string[] = []) => {
return new Promise<ChildProcessWithoutNullStreams>((resolve, reject)=> {
const ls = spawn('node', [path.join(__dirname, '../', 'dist/bin/peerjs.js'), '--port', "9000", ...params]);
ls.stdout.once("data", ()=> resolve(ls))
ls.stderr.once("data", ()=>{
ls.kill()
reject()
})
})
}