Skip to content

Commit d61e151

Browse files
chore: miscellaneous fixes (#234)
1 parent 73f0aec commit d61e151

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/cli.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
import type {Options as YargsOptions} from 'yargs';
78
import yargs from 'yargs';
89
import {hideBin} from 'yargs/helpers';
910

1011
export const cliOptions = {
1112
browserUrl: {
12-
type: 'string' as const,
13+
type: 'string',
1314
description:
1415
'Connect to a running Chrome instance using port forwarding. For more details see: https://developer.chrome.com/docs/devtools/remote-debugging/local-server.',
1516
alias: 'u',
@@ -19,43 +20,43 @@ export const cliOptions = {
1920
},
2021
},
2122
headless: {
22-
type: 'boolean' as const,
23+
type: 'boolean',
2324
description: 'Whether to run in headless (no UI) mode.',
2425
default: false,
2526
},
2627
executablePath: {
27-
type: 'string' as const,
28+
type: 'string',
2829
description: 'Path to custom Chrome executable.',
2930
conflicts: 'browserUrl',
3031
alias: 'e',
3132
},
3233
isolated: {
33-
type: 'boolean' as const,
34+
type: 'boolean',
3435
description:
3536
'If specified, creates a temporary user-data-dir that is automatically cleaned up after the browser is closed.',
3637
default: false,
3738
},
3839
customDevtools: {
39-
type: 'string' as const,
40+
type: 'string',
4041
description: 'Path to custom DevTools.',
4142
hidden: true,
4243
conflicts: 'browserUrl',
4344
alias: 'd',
4445
},
4546
channel: {
46-
type: 'string' as const,
47+
type: 'string',
4748
description:
4849
'Specify a different Chrome channel that should be used. The default is the stable channel version.',
4950
choices: ['stable', 'canary', 'beta', 'dev'] as const,
5051
conflicts: ['browserUrl', 'executablePath'],
5152
},
5253
logFile: {
53-
type: 'string' as const,
54+
type: 'string',
5455
describe:
5556
'Path to a file to write debug logs to. Set the env variable `DEBUG` to `*` to enable verbose logs. Useful for submitting bug reports.',
5657
},
5758
viewport: {
58-
type: 'string' as const,
59+
type: 'string',
5960
describe:
6061
'Initial viewport size for the Chromee instances started by the server. For example, `1280x720`',
6162
coerce: (arg: string | undefined) => {
@@ -73,14 +74,14 @@ export const cliOptions = {
7374
},
7475
},
7576
proxyServer: {
76-
type: 'string' as const,
77+
type: 'string',
7778
description: `Proxy server configuration for Chrome passed as --proxy-server when launching the browser. See https://www.chromium.org/developers/design-documents/network-settings/ for details.`,
7879
},
7980
acceptInsecureCerts: {
80-
type: 'boolean' as const,
81+
type: 'boolean',
8182
description: `If enabled, ignores errors relative to self-signed and expired certificates. Use with caution.`,
8283
},
83-
};
84+
} satisfies Record<string, YargsOptions>;
8485

8586
export function parseArguments(version: string, argv = process.argv) {
8687
const yargsInstance = yargs(hideBin(argv))

src/logger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ export function saveLogsToFile(fileName: string): fs.WriteStream {
1818
// Enable overrides everything so we need to add them
1919
debug.enable(namespacesToEnable.join(','));
2020

21-
const logFile = fs.createWriteStream(fileName, {flags: 'a'});
21+
const logFile = fs.createWriteStream(fileName, {flags: 'a+'});
2222
debug.log = function (...chunks: any[]) {
2323
logFile.write(`${chunks.join(' ')}\n`);
2424
};
2525
logFile.on('error', function (error) {
26-
console.log(`Error when opening/writing to log file: ${error.message}`);
26+
console.error(`Error when opening/writing to log file: ${error.message}`);
2727
logFile.end();
2828
process.exit(1);
2929
});

0 commit comments

Comments
 (0)