Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Commit

Permalink
Use chromium path relative to constant file (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuali925 committed Dec 2, 2020
1 parent c178f49 commit 26a5ebf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
8 changes: 1 addition & 7 deletions kibana-reports/server/routes/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,4 @@ export const DEFAULT_REPORT_HEADER = '<h1>Open Distro Kibana Reports</h1>';

export const SECURITY_AUTH_COOKIE_NAME = 'security_authentication';

export const CHROMIUM_PATHS = [
`./plugins/${PLUGIN_ID}/.chromium/headless_shell`,
'./plugins/kibana-reports/.chromium/headless_shell',
'./.chromium/headless_shell',
`../plugins/${PLUGIN_ID}/.chromium/headless_shell`,
'../plugins/kibana-reports/.chromium/headless_shell',
];
export const CHROMIUM_PATH = `${__dirname}/../../../.chromium/headless_shell`;
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
REPORT_TYPE,
FORMAT,
SELECTOR,
CHROMIUM_PATHS,
CHROMIUM_PATH,
} from '../constants';
import { getFileName } from '../helpers';
import { CreateReportResultType } from '../types';
Expand Down Expand Up @@ -50,16 +50,6 @@ export const createVisualReport = async (
report_format: reportFormat,
} = coreParams;

const getChromiumPath = () => {
const path = CHROMIUM_PATHS.find((path) => {
try {
return fs.existsSync(path);
} catch (error) {}
});
if (path) return path;
logger.error('cannot find headless chromium for puppeteer');
};

// TODO: polish default header, maybe add a logo, depends on UX design
const window = new JSDOM('').window;
const DOMPurify = createDOMPurify(window);
Expand All @@ -77,7 +67,7 @@ export const createVisualReport = async (
* https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#setting-up-chrome-linux-sandbox
*/
args: ['--no-sandbox', '--disable-setuid-sandbox'],
executablePath: getChromiumPath(),
executablePath: CHROMIUM_PATH,
});
const page = await browser.newPage();
page.setDefaultNavigationTimeout(0);
Expand Down

0 comments on commit 26a5ebf

Please sign in to comment.