11#!/usr/bin/env node
22import { parseArgs } from 'node:util' ;
3+ import { toInt } from '../src/args.mjs' ;
34import { loadConfig , ensureOutputDir } from '../src/config.mjs' ;
45import { capture } from '../src/capture.mjs' ;
56import { control } from '../src/control.mjs' ;
@@ -26,6 +27,11 @@ Options:
2627 --concurrency=<n> Parallel browser contexts for capture (default: 4).
2728 --stagger=<ms> Delay between starting capture contexts (default: 500).
2829 --skip-reload Reuse the page between viewports during capture.
30+ --insecure Ignore TLS certificate errors for non-local hosts
31+ (already ignored for .test/localhost).
32+ --fail-on-degraded Exit non-zero if any capture failed to load cleanly.
33+ --compare-concurrency=<n> Parallel diff workers for compare
34+ (default: CPU count - 1; lower it for very tall pages).
2935 --no-open Don't open the report automatically after compare.
3036 -h, --help Show this help.
3137
@@ -43,6 +49,9 @@ const { values, positionals } = parseArgs({
4349 concurrency : { type : 'string' } ,
4450 stagger : { type : 'string' } ,
4551 'skip-reload' : { type : 'boolean' } ,
52+ insecure : { type : 'boolean' } ,
53+ 'fail-on-degraded' : { type : 'boolean' } ,
54+ 'compare-concurrency' : { type : 'string' } ,
4655 'no-open' : { type : 'boolean' } ,
4756 help : { type : 'boolean' , short : 'h' } ,
4857 } ,
@@ -56,23 +65,7 @@ if (values.help || !command) {
5665}
5766
5867/**
59- * Parse an integer flag, exiting with an error when it is not a number.
60- *
61- * @param {string } value - The raw flag value.
62- * @param {string } name - The flag name, for error messages.
63- * @returns {number } The parsed integer.
64- */
65- function toInt ( value , name ) {
66- const parsed = parseInt ( value , 10 ) ;
67- if ( Number . isNaN ( parsed ) ) {
68- console . error ( `Invalid value for --${ name } : ${ value } ` ) ;
69- process . exit ( 1 ) ;
70- }
71- return parsed ;
72- }
73-
74- /**
75- *
68+ * Dispatch the parsed command.
7669 */
7770async function main ( ) {
7871 const config = loadConfig ( {
@@ -96,9 +89,11 @@ async function main() {
9689 ? toInt ( values . concurrency , 'concurrency' )
9790 : undefined ,
9891 staggerDelay : values . stagger
99- ? toInt ( values . stagger , 'stagger' )
92+ ? toInt ( values . stagger , 'stagger' , { min : 0 } )
10093 : undefined ,
10194 skipReload : values [ 'skip-reload' ] ,
95+ failOnDegraded : values [ 'fail-on-degraded' ] ,
96+ insecure : values . insecure ,
10297 } ) ;
10398 break ;
10499
@@ -107,7 +102,16 @@ async function main() {
107102 break ;
108103
109104 case 'compare' :
110- await compare ( config , { only, open : ! values [ 'no-open' ] } ) ;
105+ await compare ( config , {
106+ only,
107+ open : ! values [ 'no-open' ] ,
108+ concurrency : values [ 'compare-concurrency' ]
109+ ? toInt (
110+ values [ 'compare-concurrency' ] ,
111+ 'compare-concurrency'
112+ )
113+ : undefined ,
114+ } ) ;
111115 break ;
112116
113117 default :
0 commit comments