Files
kandev/apps/cli/src/bundle.ts
T
2026-06-18 18:36:48 +01:00

25 lines
667 B
TypeScript

import * as tar from "tar";
import fs from "node:fs";
import path from "node:path";
export function extractTarGz(archivePath: string, destDir: string): void {
tar.extract({ file: archivePath, cwd: destDir, sync: true });
}
export function ensureExtracted(archivePath: string, destDir: string): void {
const marker = path.join(destDir, ".extracted");
if (fs.existsSync(marker)) {
return;
}
extractTarGz(archivePath, destDir);
fs.writeFileSync(marker, "");
}
export function findBundleRoot(cacheDir: string): string {
const candidate = path.join(cacheDir, "kandev");
if (fs.existsSync(candidate)) {
return candidate;
}
return cacheDir;
}