import path from 'path'; import { VOLUMES_DIR } from '@iridiumcms/constants'; import * as tar from 'tar'; export const tarball = async function(directoryName: string, outputFilename: string) { const tarballPath = path.resolve(VOLUMES_DIR, outputFilename); const tarballDir = path.resolve(VOLUMES_DIR, directoryName); await tar.c({ gzip: true, file: tarballPath, cwd: tarballDir, }, ['.']); return tarballPath; }; export const untarball = async (directoryName: string, inputFilename: string) => { const tarballPath = path.resolve(VOLUMES_DIR, inputFilename); const tarballDir = path.resolve(VOLUMES_DIR, directoryName); await tar.x({ file: tarballPath, cwd: tarballDir, }); };