chromedriver.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. exports.resolveBuildId = exports.relativeExecutablePath = exports.resolveDownloadPath = exports.resolveDownloadUrl = void 0;
  7. /**
  8. * Copyright 2023 Google Inc. All rights reserved.
  9. *
  10. * Licensed under the Apache License, Version 2.0 (the "License");
  11. * you may not use this file except in compliance with the License.
  12. * You may obtain a copy of the License at
  13. *
  14. * http://www.apache.org/licenses/LICENSE-2.0
  15. *
  16. * Unless required by applicable law or agreed to in writing, software
  17. * distributed under the License is distributed on an "AS IS" BASIS,
  18. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. * See the License for the specific language governing permissions and
  20. * limitations under the License.
  21. */
  22. const path_1 = __importDefault(require("path"));
  23. const chrome_js_1 = require("./chrome.js");
  24. const types_js_1 = require("./types.js");
  25. function folder(platform) {
  26. switch (platform) {
  27. case types_js_1.BrowserPlatform.LINUX:
  28. return 'linux64';
  29. case types_js_1.BrowserPlatform.MAC_ARM:
  30. return 'mac-arm64';
  31. case types_js_1.BrowserPlatform.MAC:
  32. return 'mac-x64';
  33. case types_js_1.BrowserPlatform.WIN32:
  34. return 'win32';
  35. case types_js_1.BrowserPlatform.WIN64:
  36. return 'win64';
  37. }
  38. }
  39. function resolveDownloadUrl(platform, buildId, baseUrl = 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing') {
  40. return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
  41. }
  42. exports.resolveDownloadUrl = resolveDownloadUrl;
  43. function resolveDownloadPath(platform, buildId) {
  44. return [buildId, folder(platform), `chromedriver-${folder(platform)}.zip`];
  45. }
  46. exports.resolveDownloadPath = resolveDownloadPath;
  47. function relativeExecutablePath(platform, _buildId) {
  48. switch (platform) {
  49. case types_js_1.BrowserPlatform.MAC:
  50. case types_js_1.BrowserPlatform.MAC_ARM:
  51. return path_1.default.join('chromedriver-' + folder(platform), 'chromedriver');
  52. case types_js_1.BrowserPlatform.LINUX:
  53. return path_1.default.join('chromedriver-linux64', 'chromedriver');
  54. case types_js_1.BrowserPlatform.WIN32:
  55. case types_js_1.BrowserPlatform.WIN64:
  56. return path_1.default.join('chromedriver-' + folder(platform), 'chromedriver.exe');
  57. }
  58. }
  59. exports.relativeExecutablePath = relativeExecutablePath;
  60. async function resolveBuildId(channel) {
  61. return (await (0, chrome_js_1.getLastKnownGoodReleaseForChannel)(channel)).version;
  62. }
  63. exports.resolveBuildId = resolveBuildId;
  64. //# sourceMappingURL=chromedriver.js.map