UNPKG

@netlify/zip-it-and-ship-it

Version:
16 lines (15 loc) 508 B
import { promises as fs } from 'fs'; import { extname } from 'path'; // Returns the input object with an additional `size` property containing the // size of the file at `path` when it is a ZIP archive. export const getArchiveSize = async (path) => { if (extname(path) !== '.zip') { return; } const { size } = await fs.stat(path); return size; }; export const addArchiveSize = async (result) => { const size = await getArchiveSize(result.path); return { ...result, size }; };