tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

download_chrome_canary.mjs (1219B)


      1 /**
      2 * @license
      3 * Copyright 2024 Google Inc.
      4 * SPDX-License-Identifier: Apache-2.0
      5 */
      6 
      7 /**
      8 * @fileoverview Installs the latest Chrome Canary using
      9 * `@puppeteer/browsers` to the directory provided as the first argument
     10 * (default: cwd). The executable path is written to the `executablePath` output
     11 * param for GitHub actions.
     12 *
     13 * Examples:
     14 *
     15 * - `node tools/download_chrome_canary.mjs`
     16 * - `node tools/download_chrome_canary.mjs /tmp/cache`
     17 */
     18 import actions from '@actions/core';
     19 import {
     20  Browser,
     21  computeExecutablePath,
     22  install,
     23  resolveBuildId,
     24  detectBrowserPlatform,
     25 } from '@puppeteer/browsers';
     26 
     27 try {
     28  const cacheDir = process.argv[2] || process.cwd();
     29  const browser = Browser.CHROME;
     30  const platform = detectBrowserPlatform();
     31  const buildId = await resolveBuildId(browser, platform, 'canary');
     32  await install({
     33    browser,
     34    buildId,
     35    cacheDir,
     36  });
     37  const executablePath = computeExecutablePath({
     38    cacheDir,
     39    browser,
     40    buildId,
     41  });
     42  if (process.argv.indexOf('--shell') === -1) {
     43    actions.setOutput('executablePath', executablePath);
     44  }
     45  console.log(executablePath);
     46 } catch (err) {
     47  actions.setFailed(`Failed to download the browser: ${err.message}`);
     48 }