( url: string, opt: string | true, logger: Logger, )
| 22 | * Reads the BROWSER environment variable and decides what to do with it. |
| 23 | */ |
| 24 | export function openBrowser( |
| 25 | url: string, |
| 26 | opt: string | true, |
| 27 | logger: Logger, |
| 28 | ): void { |
| 29 | // The browser executable to open. |
| 30 | // See https://github.com/sindresorhus/open#app for documentation. |
| 31 | const browser = typeof opt === 'string' ? opt : process.env.BROWSER || '' |
| 32 | if (browser.toLowerCase().endsWith('.js')) { |
| 33 | executeNodeScript(browser, url, logger) |
| 34 | } else if (browser.toLowerCase() !== 'none') { |
| 35 | const browserArgs = process.env.BROWSER_ARGS |
| 36 | ? process.env.BROWSER_ARGS.split(' ') |
| 37 | : [] |
| 38 | startBrowserProcess(browser, browserArgs, url, logger) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | function executeNodeScript(scriptPath: string, url: string, logger: Logger) { |
| 43 | const extraArgs = process.argv.slice(2) |
no test coverage detected