From c5c70cdf959c67637d83a15cb4d517aeed57bd4d Mon Sep 17 00:00:00 2001 From: Cris Stringfellow <22254235+crislin2046@users.noreply.github.com> Date: Fri, 23 Aug 2024 11:52:15 +0800 Subject: [PATCH] Fixes seem good --- src/app.js | 4 ++-- src/common.js | 2 ++ src/launcher.js | 9 +++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/app.js b/src/app.js index 46ffaee..ef0faff 100644 --- a/src/app.js +++ b/src/app.js @@ -30,7 +30,7 @@ CHROME_OPTS.push( ] : [ ]) ); const LAUNCH_OPTS = { - logLevel: DEBUG ? 'verbose' : 'silent', + logLevel: DEBUG.verboseBrowser ? 'verbose' : 'silent', port: chrome_port, chromeFlags:CHROME_OPTS, userDataDir:false, @@ -127,7 +127,7 @@ async function start() { try { b = await ChromeLaunch(LAUNCH_OPTS); } catch(e) { - console.log(`Could not launch browser.`); + console.log(`Could not launch browser: ${e}.`); DEBUG.verboseSlow && console.info('Chrome launch error:', e); process.exit(1); } diff --git a/src/common.js b/src/common.js index 449183e..775890c 100644 --- a/src/common.js +++ b/src/common.js @@ -7,6 +7,8 @@ import {APP_ROOT as __ROOT} from './root.js'; const DEEB = false; export const DEBUG = { + showBrowser: false, + verboseBrowser: false, showList: false, showStatus: false, debugSec: false, diff --git a/src/launcher.js b/src/launcher.js index b49efca..3302882 100644 --- a/src/launcher.js +++ b/src/launcher.js @@ -2,6 +2,7 @@ import { spawn } from 'child_process'; import fs from 'fs'; import os from 'os'; import inquirer from 'inquirer'; +import {DEBUG} from './common.js'; // regular funcs and data const browserPaths = { @@ -61,15 +62,15 @@ const launchBrowser = (browser, url = '', flags = []) => { }); childProcess.stdout.on('data', (data) => { - console.log(`browser: ${data}`); + DEBUG.showBrowser && console.log(`browser: ${data}`); }); childProcess.stderr.on('data', (data) => { - console.error(`browser: ${data}`); + DEBUG.showBrowser && console.error(`browser: ${data}`); }); childProcess.on('close', (code) => { - console.log(`child process exited with code ${code}`); + console.log(`browser process exited with code ${code}`); }); childProcess.unref(); @@ -101,7 +102,7 @@ const launch = async (opts = {}) => { fullAsk = false, } = opts; - console.log({opts,startingUrl}); + DEBUG.showBrowser && console.log({opts,startingUrl}); const installedBrowsers = getInstalledBrowsers(); if (installedBrowsers.length === 0) { console.error('No supported browsers are installed.');