diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 12f7b83d..4081cec5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,8 +7,6 @@ jobs: - job: Linux pool: vmImage: 'ubuntu-16.04' - variables: - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1 steps: - task: NodeTool@0 inputs: @@ -42,8 +40,6 @@ jobs: - job: macOS pool: vmImage: 'xcode9-macos10.13' - variables: - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1 steps: - task: NodeTool@0 inputs: @@ -64,8 +60,6 @@ jobs: - job: Windows pool: vmImage: 'vs2017-win2016' - variables: - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1 steps: - task: NodeTool@0 inputs: @@ -139,8 +133,6 @@ jobs: condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['FORCE_RELEASE'], 'true'))) pool: vmImage: 'ubuntu-16.04' - variables: - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1 steps: - task: NodeTool@0 inputs: diff --git a/bin/download_browser.js b/bin/download_browser.js new file mode 100644 index 00000000..44380db2 --- /dev/null +++ b/bin/download_browser.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2020 The xterm.js authors. All rights reserved. + * @license MIT + */ + +const playwright = require('playwright-core'); +const fs = require('fs'); + +// Default to chromium +let browserType = playwright['chromium']; +const index = process.argv.indexOf('--browser'); +if (index !== -1 && process.argv.length > index + 1 && typeof process.argv[index + 1] === 'string') { + const string = process.argv[index + 1]; + if (string === 'firefox' || string === 'webkit') { + browserType = playwright[string]; + } +} + +const exists = fs.existsSync(browserType.executablePath()); +if (!exists) { + console.log(`Downloading ${browserType.name()}`); + browserType.downloadBrowserIfNeeded().then(() => process.exit(0)); +} diff --git a/package.json b/package.json index 0946688f..88467328 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,9 @@ "test-api-chromium": "mocha \"**/*.api.js\" --browser chromium --timeout 10000", "test-api-firefox": "mocha \"**/*.api.js\" --browser firefox --timeout 10000", "test-api-webkit": "mocha \"**/*.api.js\" --browser webkit --timeout 10000", + "pretest-api-chromium": "node ./bin/download_browser.js --browser chromium", + "pretest-api-firefox": "node ./bin/download_browser.js --browser firefox", + "pretest-api-webkit": "node ./bin/download_browser.js --browser webkit", "test-unit": "node ./bin/test.js", "test-unit-coverage": "node ./bin/test.js --coverage", "build": "tsc -b ./tsconfig.all.json", diff --git a/test/api/TestUtils.ts b/test/api/TestUtils.ts index 7bad9b8f..60044746 100644 --- a/test/api/TestUtils.ts +++ b/test/api/TestUtils.ts @@ -46,7 +46,7 @@ export async function getBrowserType(): Promise { let browserType: playwright.BrowserType = playwright['chromium']; const index = process.argv.indexOf('--browser'); - if (index !== -1 && process.argv.length > index + 2 && typeof process.argv[index + 1] === 'string') { + if (index !== -1 && process.argv.length > index + 1 && typeof process.argv[index + 1] === 'string') { const string = process.argv[index + 1]; if (string === 'firefox' || string === 'webkit') { browserType = playwright[string];