UNPKG

askui

Version:

Reliable, automated end-to-end-testing that depends on what is shown on your screen instead of the technology you are running on

74 lines (73 loc) 3.48 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProxyImportError = void 0; exports.envProxyAgents = envProxyAgents; const logger_1 = require("../../lib/logger"); class ProxyImportError extends Error { } exports.ProxyImportError = ProxyImportError; function dynmicImportHpagent() { return __awaiter(this, void 0, void 0, function* () { try { // eslint-disable-next-line import/no-extraneous-dependencies return yield Promise.resolve().then(() => __importStar(require('hpagent'))); } catch (err) { throw new ProxyImportError('Can\'t find "hpagent" module to configure proxy!' + ' Please, install hpagent for proxy support with' + ' "npm install --save-dev hpagent" or "npm install --save hpagent".'); } }); } function envProxyAgents() { return __awaiter(this, void 0, void 0, function* () { const httpProxyUrl = process.env['HTTP_PROXY']; const httpsProxyUrl = process.env['HTTPS_PROXY']; if (httpProxyUrl === undefined && httpsProxyUrl === undefined) { logger_1.logger.debug('No proxy defined. "HTTPS_PROXY" and "HTTP_PROXY" environment variables are empty.'); return undefined; } const hpagent = yield dynmicImportHpagent(); logger_1.logger.info('Using proxy! One of following environment variables are defined: "HTTPS_PROXY", "https_proxy", "HTTP_PROXY" and "http_proxy"'); return { http: new hpagent.HttpProxyAgent({ proxy: (httpProxyUrl || httpsProxyUrl), }), https: new hpagent.HttpsProxyAgent({ proxy: (httpsProxyUrl || httpProxyUrl), }), }; }); }