How to use the @actions/tool-cache.extract7z function in @actions/tool-cache

To help you get started, we’ve selected a few @actions/tool-cache 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 Geertvdc / setup-hub / src / installer.ts View on Github external
destinationFolder: string
): Promise {
  const stats = fs.statSync(file);
  if (!stats) {
    throw new Error(`Failed to extract ${file} - it doesn't exist`);
  } else if (stats.isDirectory()) {
    throw new Error(`Failed to extract ${file} - it is a directory`);
  }

  if ('.tgz' === fileEnding) {
    await tc.extractTar(file, destinationFolder);
  } else if ('.zip' === fileEnding) {
    await tc.extractZip(file, destinationFolder);
  } else {
    // fall through and use sevenZip
    await tc.extract7z(file, destinationFolder);
  }
}
github actions / setup-node / src / installer.ts View on Github external
downloadPath = await tc.downloadTool(downloadUrl);
  } catch (err) {
    if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
      return await acquireNodeFromFallbackLocation(version);
    }

    throw err;
  }

  //
  // Extract
  //
  let extPath: string;
  if (osPlat == 'win32') {
    let _7zPath = path.join(__dirname, '..', 'externals', '7zr.exe');
    extPath = await tc.extract7z(downloadPath, undefined, _7zPath);
  } else {
    extPath = await tc.extractTar(downloadPath);
  }

  //
  // Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
  //
  let toolRoot = path.join(extPath, fileName);
  return await tc.cacheDir(toolRoot, 'node', version);
}
github mihails-strasuns / setup-dlang / src / main.ts View on Github external
async function extract(format: string, archive: string, into?: string) {
    if (format.endsWith(".7z"))
        return await tc.extract7z(archive, into);
    else if (format.endsWith(".zip"))
        return await tc.extractZip(archive, into);
    else if (/\.tar(\.\w+)?$/.test(format))
        return await tc.extractTar(archive, into, 'x');

    throw new Error("unsupported archive format: " + format);
}
github WebFreak001 / setup-dmd / src / main.ts View on Github external
}
    }
  }

  if (!url.length || type === undefined)
    throw new Error(`Failed to determine dmd download URL for version ${dmdVersion}`);

  core.debug("Downloading DMD from " + url);
  const tmppath = await tc.downloadTool(url);
  let dstdir: string;
  switch (type) {
    case "tarxz":
      dstdir = await tc.extractTar(tmppath);
      break;
    case "7z":
      dstdir = await tc.extract7z(tmppath);
      break;
    case "zip":
      dstdir = await tc.extractZip(tmppath);
      break;
    default: throw new Error("unexpected program state");
  }

  if (dmdVersion !== "master")
    tc.cacheDir(dstdir, "dmd", dmdVersion);

  return dstdir;
}
github GoogleCloudPlatform / github-actions / setup-gcloud / src / download-util.ts View on Github external
export async function downloadAndExtractTool(url: string): Promise {
  const downloadPath = await toolCache.downloadTool(url);
  let extractedPath: string;
  if (url.indexOf('.zip') != -1) {
    extractedPath = await toolCache.extractZip(downloadPath);
  } else if (url.indexOf('.tar.gz') != -1) {
    extractedPath = await toolCache.extractTar(downloadPath);
  } else if (url.indexOf('.7z') != -1) {
    extractedPath = await toolCache.extract7z(downloadPath);
  } else {
    throw new Error(
      `Unexpected download archive type, downloadPath: ${downloadPath}`,
    );
  }
  return extractedPath;
}