Skip to content

Commit b2ace7e

Browse files
authored
fix: only set env.DEBUG_COLORS='true' for the plugin (#51)
1 parent f50cc18 commit b2ace7e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/lighthouse.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
// prevent logger from prefixing a date when running in tty
1+
// we set DEBUG_COLORS = 'true' to prevent the logger from prefixing a date when running in tty
2+
// keep the old DEBUG_COLORS value so we can return it to the original value
3+
let debugColorsSet = false;
4+
let debugColorsOriginalValue;
5+
if ('DEBUG_COLORS' in process.env) {
6+
debugColorsSet = true;
7+
debugColorsOriginalValue = process.env.DEBUG_COLORS;
8+
}
29
process.env.DEBUG_COLORS = 'true';
310

411
const puppeteer = require('puppeteer');
512
const lighthouse = require('lighthouse');
613
const log = require('lighthouse-logger');
714
const chromeLauncher = require('chrome-launcher');
815

16+
// we can return the original value after requiring the dependencies
17+
if (debugColorsSet) {
18+
process.env.DEBUG_COLORS = debugColorsOriginalValue;
19+
} else {
20+
delete process.env.DEBUG_COLORS;
21+
}
22+
923
const getBrowserPath = async () => {
1024
const browserFetcher = puppeteer.createBrowserFetcher();
1125
const revisions = await browserFetcher.localRevisions();

0 commit comments

Comments
 (0)