Skip to content

Commit

Permalink
Fix: file size calculation with gzip compression
Browse files Browse the repository at this point in the history
  • Loading branch information
LironEr committed Aug 17, 2020
1 parent 51bc36b commit 2ea62d0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/bundlemon/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bundlemon",
"version": "0.1.0",
"version": "0.1.1",
"description": "Monitor your bundle size",
"keywords": [
"bundle",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
5 changes: 3 additions & 2 deletions packages/bundlemon/src/main/analyzer/getFileSize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import type { Compression } from 'bundlemon-utils';

export async function getFileSize(path: string, compression: Compression): Promise<number> {
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;
Expand Down

0 comments on commit 2ea62d0

Please sign in to comment.