Skip to content

Commit 5d361cf

Browse files
committed
add logging
1 parent b6f15ea commit 5d361cf

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

src/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ dotenv.config();
1111
const puppeteerCacheDir = join(homedir(), '.cache', 'puppeteer');
1212

1313
const onPreBuild = async ({ utils } = {}) => {
14+
console.log('onPreBuild handler called');
1415
console.log('Restoring Lighthouse cache...');
1516
// Puppeteer relies on a global cache since v19.x, which otherwise would not be persisted in Netlify builds
1617
await utils?.cache.restore(puppeteerCacheDir);
@@ -24,6 +25,7 @@ const persistCache = async ({ utils } = {}) => {
2425
};
2526

2627
export default function lighthousePlugin(inputs) {
28+
console.log('lighthouse plugin function called with inputs:', JSON.stringify(inputs, null, 2));
2729
// Run onSuccess by default, unless inputs specify we should fail_deploy_on_score_thresholds
2830
const defaultEvent =
2931
inputs?.fail_deploy_on_score_thresholds === 'true'
@@ -33,8 +35,12 @@ export default function lighthousePlugin(inputs) {
3335
if (defaultEvent === 'onSuccess') {
3436
return {
3537
onPreBuild,
36-
onPostBuild: ({ utils }) => persistCache({ utils }),
38+
onPostBuild: ({ utils }) => {
39+
console.log('onPostBuild handler called (onSuccess mode)');
40+
return persistCache({ utils });
41+
},
3742
onSuccess: async ({ constants, utils, inputs } = {}) => {
43+
console.log('onSuccess handler called');
3844
// Mock the required `utils` functions if running locally
3945
const { failPlugin, show } = getUtils({ utils });
4046

@@ -51,6 +57,7 @@ export default function lighthousePlugin(inputs) {
5157
return {
5258
onPreBuild,
5359
onPostBuild: async ({ constants, utils, inputs } = {}) => {
60+
console.log('onPostBuild handler called (onPostBuild mode)');
5461
// Mock the required `utils` functions if running locally
5562
const { failBuild, show } = getUtils({ utils });
5663

src/lib/run-audit-with-server/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const runAuditWithServer = async ({
1616
try {
1717
const { server } = getServer({ serveDir: serveDir, auditUrl: url });
1818

19-
const browserPath = await getBrowserPath();
19+
const browserPath = getBrowserPath();
2020

2121
const { error, results } = await new Promise((resolve) => {
2222
const instance = server.listen(async () => {

src/lib/run-audit-with-url/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { runLighthouse, getBrowserPath } from '../../run-lighthouse.js';
33

44
const runAuditWithUrl = async ({ path = '', url, thresholds, settings }) => {
55
try {
6-
const browserPath = await getBrowserPath();
6+
const browserPath = getBrowserPath();
77

88
const getResults = async () => {
99
const fullPath = path ? `${url}/${path}` : url;

src/run-lighthouse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import chromeLauncher from 'chrome-launcher';
66
// Cache the browser path to avoid multiple launches
77
let cachedBrowserPath;
88

9-
export const getBrowserPath = async () => {
9+
export const getBrowserPath = () => {
1010
if (cachedBrowserPath) {
1111
return cachedBrowserPath;
1212
}

0 commit comments

Comments
 (0)