Skip to content

Commit

Permalink
core: fix crash with Sentry init (#13104)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark authored Sep 22, 2021
1 parent 7435bf9 commit 15c4300
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lighthouse-cli/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import fs from 'fs';
import path from 'path';
import url from 'url';
import module from 'module';

import log from 'lighthouse-logger';
import updateNotifier from 'update-notifier';
Expand All @@ -30,12 +31,15 @@ import * as Printer from './printer.js';
import {getFlags} from './cli-flags.js';
import {runLighthouse} from './run.js';
import lighthouse from '../lighthouse-core/index.js';
import * as Sentry from '../lighthouse-core/lib/sentry.js';
import {askPermission} from './sentry-prompt.js';
import {LH_ROOT} from '../root.js';

const pkg = JSON.parse(fs.readFileSync(LH_ROOT + '/package.json', 'utf-8'));

// TODO(esmodules): use regular import when this file is esm.
const require = module.createRequire(import.meta.url);
const Sentry = require('../lighthouse-core/lib/sentry.js');

/**
* @return {boolean}
*/
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-cli/test/cli/bin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jest.unstable_mockModule('../../sentry-prompt.js', () => {
});

const mockSentryInit = jest.fn();
jest.unstable_mockModule('../../../lighthouse-core/lib/sentry.js', () => {
jest.mock('../../../lighthouse-core/lib/sentry.js', () => {
return {init: mockSentryInit};
});

Expand Down

0 comments on commit 15c4300

Please sign in to comment.