File tree Expand file tree Collapse file tree 2 files changed +9
-13
lines changed
lib/run-audit-with-server Expand file tree Collapse file tree 2 files changed +9
-13
lines changed Original file line number Diff line number Diff line change 11import { join } from 'path' ;
22
33import { formatResults } from '../../format.js' ;
4- import { runLighthouse } from '../../run-lighthouse.js' ;
4+ import { runLighthouse , getBrowserPath } from '../../run-lighthouse.js' ;
55import persistResults from '../persist-results/index.js' ;
66import getServer from '../get-server/index.js' ;
77
@@ -16,13 +16,13 @@ const runAuditWithServer = async ({
1616 try {
1717 const { server } = getServer ( { serveDir : serveDir , auditUrl : url } ) ;
1818
19-
19+ const browserPath = await getBrowserPath ( ) ;
2020
2121 const { error, results } = await new Promise ( ( resolve ) => {
2222 const instance = server . listen ( async ( ) => {
2323 try {
2424 const fullPath = path ? `${ server . url } /${ path } ` : server . url ;
25- const results = await runLighthouse ( "PLACEHOLDER" , fullPath , settings ) ;
25+ const results = await runLighthouse ( browserPath , fullPath , settings ) ;
2626 resolve ( { error : false , results } ) ;
2727 } catch ( error ) {
2828 resolve ( { error } ) ;
Original file line number Diff line number Diff line change @@ -2,22 +2,18 @@ import puppeteer from 'puppeteer';
22import lighthouse from 'lighthouse' ;
33import log from 'lighthouse-logger' ;
44
5- // export const getBrowserPath = async () => {
6- // const browserFetcher = new BrowserFetcher();
7- // const revisions = await browserFetcher.localRevisions();
8- // if (revisions.length <= 0) {
9- // throw new Error('Could not find local browser');
10- // }
11- // const info = await browserFetcher.revisionInfo(revisions[0]);
12- // return info.executablePath;
13- // };
5+ export const getBrowserPath = async ( ) => {
6+ // In newer Puppeteer versions, we can get the executable path directly
7+ return puppeteer . executablePath ( ) ;
8+ } ;
149
15- export const runLighthouse = async ( url , settings ) => {
10+ export const runLighthouse = async ( browserPath , url , settings ) => {
1611 let chrome ;
1712 try {
1813 const logLevel = 'error' ;
1914 log . setLevel ( logLevel ) ;
2015 chrome = await puppeteer . launch ( {
16+ executablePath : browserPath ,
2117 args : [
2218 '--headless' ,
2319 '--no-sandbox' ,
You can’t perform that action at this time.
0 commit comments