Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function main() {
const rootURL = process.env.LHCI_ROOT_URL;
if (!rootURL) throw new Error(`Missing LHCI_ROOT_URL environment variable`);
const client = new ApiClient({rootURL});
const projects = await client.getProjects();
const project = projects.find(project => project.name.includes('Viewer')) || projects[0];
const builds = await client.getBuilds(project.id);
const build = builds.find(build => build.branch.includes('test_1')) || builds[0];
process.stdout.write(
[
new URL(`/app`, rootURL),
new URL(`/app/projects/${project.slug}`, rootURL),
new URL(`/app/projects/${project.slug}/compare/${_.shortId(build.id)}`, rootURL),
].join('\n')
);
process.exit(0);
}
onClick={() =>
route(`/app/projects/${project.slug}/compare/${_.shortId(build.id)}`)
}
onClick={({points}) => {
const currentUrl = new URL(window.location.href);
const x = points[0].x;
const to = `${currentUrl.pathname}/compare/${_.shortId(builds[x].id)}`;
route(to);
}}
data={ys.map((yVals, i) => ({
onClick={() => {
if (isCompareBranch && selector === 'compare') return;
if (isBaseBranch && selector === 'base') return;
const url = new URL(window.location.href);
if (selector === 'base') {
url.searchParams.set('baseBuild', build.id);
} else {
url.searchParams.delete('baseBuild');
if (baseBuild) url.searchParams.set('baseBuild', baseBuild.id);
url.pathname = url.pathname.replace(/compare\/\w+$/, `compare/${_.shortId(build.id)}`);
}
window.location.href = url.href;
}}
>