core/postinstall.js
function getRequestOptions(conf) {
  const strictSSL = conf.get('strict-ssl');

  let options = {
    uri: downloadUrl,
    encoding: null, // Get response as a buffer
    followRedirect: true, // The default download path redirects to a CDN URL.
    headers: {},
    strictSSL: strictSSL
  };

  let proxyUrl = conf.get('https-proxy') || conf.get('http-proxy') || conf.get('proxy');
  if (proxyUrl) {

    // Print using proxy
    let proxy = url.parse(proxyUrl);
    if (proxy.auth) {
      // Mask password
      proxy.auth = proxy.auth.replace(/:.*$/, ':******');
    }
    log.info('Using proxy ' + url.format(proxy));

    // Enable proxy
    options.proxy = proxyUrl;

    // If going through proxy, use the user-agent string from the npm config
    options.headers['User-Agent'] = conf.get('user-agent');
  }

  // Use certificate authority settings from npm
  const ca = conf.get('ca');
  if (ca) {
    log.info('Using npmconf ca');
    options.ca = ca;
  }

  return options;
}
function getRequestOptions(conf) {
  const strictSSL = conf.get('strict-ssl');

  let options = {
    uri: downloadUrl,
    encoding: null, // Get response as a buffer
    followRedirect: true, // The default download path redirects to a CDN URL.
    headers: {},
    strictSSL: strictSSL
  };

  let proxyUrl = conf.get('https-proxy') || conf.get('http-proxy') || conf.get('proxy');
  if (proxyUrl) {

    // Print using proxy
    let proxy = url.parse(proxyUrl);
    if (proxy.auth) {
      // Mask password
      proxy.auth = proxy.auth.replace(/:.*$/, ':******');
    }
    log.info('Using proxy ' + url.format(proxy));

    // Enable proxy
    options.proxy = proxyUrl;

    // If going through proxy, use the user-agent string from the npm config
    options.headers['User-Agent'] = conf.get('user-agent');
  }

  // Use certificate authority settings from npm
  const ca = conf.get('ca');
  if (ca) {
    log.info('Using npmconf ca');
    options.ca = ca;
  }

  return options;
}
function getRequestOptions ( conf ) { const strictSSL = conf . get ( 'strict-ssl' ) ; let options = { uri : downloadUrl , encoding : null , // Get response as a buffer followRedirect : true , // The default download path redirects to a CDN URL. headers : { } , strictSSL : strictSSL } ; let proxyUrl = conf . get ( 'https-proxy' ) || conf . get ( 'http-proxy' ) || conf . get ( 'proxy' ) ; if ( proxyUrl ) { // Print using proxy let proxy = url . parse ( proxyUrl ) ; if ( proxy . auth ) { // Mask password proxy . auth = proxy . auth . replace ( / :.*$ / , ':******' ) ; } log . info ( 'Using proxy ' + url . format ( proxy ) ) ; // Enable proxy options . proxy = proxyUrl ; // If going through proxy, use the user-agent string from the npm config options . headers [ 'User-Agent' ] = conf . get ( 'user-agent' ) ; } // Use certificate authority settings from npm const ca = conf . get ( 'ca' ) ; if ( ca ) { log . info ( 'Using npmconf ca' ) ; options . ca = ca ; } return options ; }
Create request opions object
@param {object} conf - current NPM config
@returns {{uri: string, encoding: null, followRedirect: boolean, headers: {}, strictSSL: *}}
@function
Create request opions object