Fixes seem good

This commit is contained in:
Cris Stringfellow 2024-08-23 11:52:15 +08:00
parent 96a0b32257
commit c5c70cdf95
No known key found for this signature in database
3 changed files with 9 additions and 6 deletions

View File

@ -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);
}

View File

@ -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,

View File

@ -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.');