From 2ea62d01a9532fff9305197d813034a3313c4284 Mon Sep 17 00:00:00 2001 From: Liron Erman Date: Mon, 17 Aug 2020 13:42:12 +0300 Subject: [PATCH] Fix: file size calculation with gzip compression --- packages/bundlemon/package.json | 2 +- .../src/main/analyzer/__tests__/getFileSize.spec.ts | 2 +- packages/bundlemon/src/main/analyzer/getFileSize.ts | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/bundlemon/package.json b/packages/bundlemon/package.json index 3e5edfe..da39cb6 100644 --- a/packages/bundlemon/package.json +++ b/packages/bundlemon/package.json @@ -1,6 +1,6 @@ { "name": "bundlemon", - "version": "0.1.0", + "version": "0.1.1", "description": "Monitor your bundle size", "keywords": [ "bundle", diff --git a/packages/bundlemon/src/main/analyzer/__tests__/getFileSize.spec.ts b/packages/bundlemon/src/main/analyzer/__tests__/getFileSize.spec.ts index 3cf76bd..97b8f5b 100644 --- a/packages/bundlemon/src/main/analyzer/__tests__/getFileSize.spec.ts +++ b/packages/bundlemon/src/main/analyzer/__tests__/getFileSize.spec.ts @@ -23,7 +23,7 @@ describe('getFileSize', () => { }); test('comperssion: gzip', async () => { - mocked(gzipSize).mockResolvedValue(expectedSize); + mocked(gzipSize.file).mockResolvedValue(expectedSize); const size = await getFileSize('path', 'gzip'); diff --git a/packages/bundlemon/src/main/analyzer/getFileSize.ts b/packages/bundlemon/src/main/analyzer/getFileSize.ts index 3555023..494ea81 100644 --- a/packages/bundlemon/src/main/analyzer/getFileSize.ts +++ b/packages/bundlemon/src/main/analyzer/getFileSize.ts @@ -5,8 +5,9 @@ import type { Compression } from 'bundlemon-utils'; export async function getFileSize(path: string, compression: Compression): Promise { switch (compression) { - case 'gzip': - return await gzipSize(path); + case 'gzip': { + return await gzipSize.file(path); + } case 'none': default: return (await fs.promises.readFile(path)).byteLength;