INNER CODE UNIT · JavaScript

buildDownloadUrl

agent-sh/agentsys · lib/binary/index.js:168

function buildDownloadUrl(ver, platformKey) {
  const ext = process.platform === 'win32' ? '.zip' : '.tar.gz';
  return 'https://github.com/' + GITHUB_REPO + '/releases/download/v' + ver + '/' + BINARY_NAME + '-' + platformKey + ext;
}

/**
 * Download a URL to a Buffer, following up to 5 redirects.
 * Supports GITHUB_TOKEN / GH_TOKEN for auth.
 * @param {string} url
 * @returns {Promise<Buffer>}
 */
function downloadToBuffer(url) {
  return new Promise(function(resolve, reject) {
    const ghToken = process.env.GITHUB_TOKEN || process.env.GH_TOKEN;

    function request(reqUrl, redirectCount) {
      if (redirectCount > 5) {
        reject(new Error('Too many redirects fetching from ' + url));

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…