How to use the download.default function in download

To help you get started, we’ve selected a few download 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 crazy-max / ghaction-docker-buildx / src / installer.ts View on Github external
export async function getBuildx(version: string): Promise {
  const selected = await determineVersion(version);
  if (selected) {
    version = selected;
  }

  const cliPluginsDir = path.join(os.homedir(), '.docker', 'cli-plugins');
  const pluginName = osPlat == 'win32' ? 'docker-buildx.exe' : 'docker-buildx';
  const downloadUrl = util.format(
    'https://github.com/docker/buildx/releases/download/%s/%s',
    version,
    getFileName(version)
  );

  console.log(`⬇️ Downloading ${downloadUrl}...`);
  await download.default(downloadUrl, cliPluginsDir, {filename: pluginName});

  if (osPlat !== 'win32') {
    await exec.exec('chmod', ['a+x', path.join(cliPluginsDir, pluginName)]);
  }

  return path.join(cliPluginsDir, pluginName);
}