Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
const ARCHIVE_SUFFIXES: Array<{ kind: string; suffixes: string[] }> = [
|
|
{ kind: "tar.gz", suffixes: [".tar.gz", ".tgz"] },
|
|
{ kind: "tar.bz2", suffixes: [".tar.bz2", ".tbz2", ".tar.bzip2"] },
|
|
{ kind: "tar.xz", suffixes: [".tar.xz", ".txz"] },
|
|
{ kind: "tar.zst", suffixes: [".tar.zst", ".tzst"] },
|
|
{ kind: "tar", suffixes: [".tar"] },
|
|
{ kind: "zip", suffixes: [".zip"] },
|
|
{ kind: "gz", suffixes: [".gz"] },
|
|
{ kind: "bz2", suffixes: [".bz2"] },
|
|
{ kind: "xz", suffixes: [".xz"] },
|
|
];
|
|
|
|
function archiveBaseName(fileName: string): string {
|
|
const normalized = String(fileName || "").replace(/\\/g, "/");
|
|
const parts = normalized.split("/");
|
|
return parts[parts.length - 1] || "";
|
|
}
|
|
|
|
export function getSftpArchiveKind(fileName: string): string | null {
|
|
const base = archiveBaseName(fileName).toLowerCase();
|
|
if (!base) return null;
|
|
for (const entry of ARCHIVE_SUFFIXES) {
|
|
if (entry.suffixes.some((suffix) => base.endsWith(suffix) && base.length > suffix.length)) {
|
|
return entry.kind;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
export function isExtractableArchive(fileName: string): boolean {
|
|
return getSftpArchiveKind(fileName) != null;
|
|
}
|