INNER CODE UNIT · TypeScript

ArchiveError

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

export class ArchiveError extends Error {}

/**
 * `tar` argv that gzips `sourcePath`'s basename as the archive's single
 * top-level member. `target` is an output file path, or `"-"` for stdout.
 */
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) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…