How to use global-agent - 4 common examples

To help you get started, we’ve selected a few global-agent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cyclosproject / ng-swagger-gen / ng-swagger-gen.js View on Github external
function setupProxy() {
  var globalAgent = require('global-agent');
  var globalTunnel = require('global-tunnel-ng');
  var proxyAddress = getProxyAndSetupEnv();

  const NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10);
  if (NODEJS_VERSION >= 10 && proxyAddress) {
    // `global-agent` works with Node.js v10 and above.
    globalAgent.bootstrap();
    global.GLOBAL_AGENT.HTTP_PROXY = proxyAddress;
  } else {
    // `global-tunnel-ng` works only with Node.js v10 and below.
    globalTunnel.initialize();
  }
}
github yeoman / yo / lib / cli.js View on Github external
const stringLength = require('string-length');
const rootCheck = require('root-check');
const meow = require('meow');
const list = require('cli-list');
const Tabtab = require('tabtab');
const pkg = require('../package.json');
const Router = require('./router');

const gens = list(process.argv.slice(2));

// Override http networking to go through a proxy ifone is configured
const MAJOR_NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10);

if (MAJOR_NODEJS_VERSION >= 10) {
  // `global-agent` works with Node.js v10 and above.
  require('global-agent').bootstrap();
} else {
  // `global-tunnel-ng` works only with Node.js v10 and below.
  require('global-tunnel-ng').initialize();
}

/* eslint new-cap: 0, no-extra-parens: 0 */
const tabtab = new Tabtab.Commands.default({
  name: 'yo',
  completer: 'yo-complete'
});

const cli = gens.map(gen => {
  const minicli = meow({help: false, pkg, argv: gen});
  const opts = minicli.flags;
  const args = minicli.input;
github yeoman / doctor / lib / cli.js View on Github external
#!/usr/bin/env node
'use strict';
require('.')();

// Override http networking to go through a proxy if one is configured.
const MAJOR_NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10);

if (MAJOR_NODEJS_VERSION >= 10) {
  // `global-agent` works with Node.js v10 and above.
  require('global-agent').bootstrap();
} else {
  // `global-tunnel-ng` works only with Node.js v10 and below.
  require('global-tunnel-ng').initialize();
}
github n4bb12 / verdaccio-github-oauth-ui / src / server / plugin / ProxyAgent.ts View on Github external
export function registerGlobalProxyAgent() {
  bootstrap()
  const config = JSON.stringify(GLOBAL_AGENT || {})
  logger.log("Proxy config:", config)
}

global-agent

Global HTTP/HTTPS proxy configurable using environment variables.

BSD-3-Clause
Latest version published 1 year ago

Package Health Score

67 / 100
Full package analysis

Popular global-agent functions