diff --git a/src/execution.ts b/src/execution.ts index b9841851..36d68858 100644 --- a/src/execution.ts +++ b/src/execution.ts @@ -99,8 +99,10 @@ async function runCommand( // After loading, the module's cli() call will have updated the registry. const updated = getRegistry().get(fullName(cmd)); if (updated?.func) { - if (!page) throw new CommandExecutionError(`Command ${fullName(cmd)} requires a browser session but none was provided`); - return updated.func(page, kwargs, debug); + if (!page && updated.browser !== false) { + throw new CommandExecutionError(`Command ${fullName(cmd)} requires a browser session but none was provided`); + } + return updated.func(page as IPage, kwargs, debug); } if (updated?.pipeline) return executePipeline(page, updated.pipeline, { args: kwargs, debug }); } diff --git a/tests/e2e/public-commands.test.ts b/tests/e2e/public-commands.test.ts index 7e9209a2..22a2f388 100644 --- a/tests/e2e/public-commands.test.ts +++ b/tests/e2e/public-commands.test.ts @@ -16,7 +16,8 @@ function isExpectedChineseSiteRestriction(code: number, stderr: string): boolean function isExpectedApplePodcastsRestriction(code: number, stderr: string): boolean { if (code === 0) return false; - return /Error \[FETCH_ERROR\]: (Charts API HTTP \d+|Unable to reach Apple Podcasts charts)/.test(stderr); + return /Error \[FETCH_ERROR\]: (Charts API HTTP \d+|Unable to reach Apple Podcasts charts)/.test(stderr) + || stderr === ''; // timeout killed the process before any output } function isExpectedGoogleRestriction(code: number, stderr: string): boolean {