Skip to content

Commit

Permalink
fix: throw error if no routes could be scanned
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Mar 3, 2024
1 parent db78086 commit 574bf87
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/cli/src/ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ async function run() {

await setCiContext()
await start()
if (worker.monitor().status === 'completed') {
logger.error('Failed to queue routes for scanning. Please check the logs with debug enabled.')
process.exit(1)
}

hooks.hook('worker-finished', async () => {
const end = new Date()
Expand Down
7 changes: 6 additions & 1 deletion packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@ async function run() {
await unlighthouse.setServerContext({ url: server.url, server: server.server, app })
await unlighthouse.start()

const logger = useLogger()
if (unlighthouse.worker.monitor().status === 'completed') {
logger.error('Failed to queue routes for scanning. Please check the logs with debug enabled.')
process.exit(1)
}

unlighthouse.hooks.hook('worker-finished', () => {
const end = new Date()
const seconds = Math.round((end.getTime() - start.getTime()) / 1000)
const logger = useLogger()

logger.success(`Unlighthouse has finished scanning \`${unlighthouse.resolvedConfig.site}\`: ${unlighthouse.worker.reports().length} routes in \`${seconds}s\`.`)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/puppeteer/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export async function createUnlighthouseWorker(tasks: Record<UnlighthouseTask, T
if (resolvedConfig.scanner.include || resolvedConfig.scanner.exclude) {
const filter = createFilter(resolvedConfig.scanner)
if (!filter(path)) {
logger.debug('Skipping route based on include / exclude rules', {
logger.info('Skipping route based on include / exclude rules', {
path,
include: resolvedConfig.scanner.include,
exclude: resolvedConfig.scanner.exclude,
Expand Down

0 comments on commit 574bf87

Please sign in to comment.