INNER CODE UNIT · TypeScript

createTarGzArgs

software-mansion/argent · packages/archive/src/index.ts:26

export function createTarGzArgs(sourcePath: string, target: string): string[] {
  return ["-czf", target, "-C", dirname(sourcePath), basename(sourcePath)];
}

/**
 * Gzip `sourcePath` (file or directory) into the tar file at `tarPath`. Removes
 * the partial archive if `tar` fails, so a mid-write failure doesn't leak it.
 */
export async function createTarGzFile(sourcePath: string, tarPath: string): Promise<void> {
  try {
    await execFileAsync("tar", createTarGzArgs(sourcePath, tarPath));
  } catch (err) {
    await rm(tarPath, { force: true }).catch(() => {});
    throw err;
  }
}

function normalizeTarMemberPath(memberPath: string): string {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…