import fsPromises from 'fs/promises' import path from 'path' import logging from '../logging' export const MAX_REPORT_SIZE = 10 * 1024 * 1024 // 10M export async function sizeCheck(baseDir:string, files: string[]) { let size = 0 for (const file of files) { const filePath = path.join(baseDir, file) const stat = await fsPromises.stat(filePath) size += stat.size } logging.info(`The total size of report is ${size/1024} KB`) if (size > MAX_REPORT_SIZE) { throw new Error(`The report is too large (>10M), abort uploading`) } }