launcher: minor cleanup

This commit is contained in:
CanadaHonk 2023-01-08 13:42:09 +00:00
parent 865b0e3714
commit acd4cdedcf

View File

@ -4,9 +4,10 @@ import ConnectCDP from '../lib/cdp.js';
import InjectInto from './inject.js';
const portRange = [ 10000, 60000 ];
const generatePort = () => (Math.floor(Math.random() * (portRange[1] - portRange[0] + 1)) + portRange[0]);
export default async (browserPath, args, transport, extra) => {
const port = transport === 'websocket' ? (Math.floor(Math.random() * (portRange[1] - portRange[0] + 1)) + portRange[0]) : null;
const port = transport === 'websocket' ? generatePort() : null;
const proc = spawn(browserPath, [
transport === 'stdio' ? `--remote-debugging-pipe` : `--remote-debugging-port=${port}`,