Skip to content

Commit fa081c5

Browse files
committed
v2.0.7 oops! Update compress.ts
1 parent faccab7 commit fa081c5

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vite-plugin-singlefile-compression",
3-
"version": "2.0.6",
3+
"version": "2.0.7",
44
"author": "bddjr",
55
"license": "MIT",
66
"description": "",

src/compress.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ export type compressor = ((buf: zlib.InputType) => Buffer)
2323
export type compressFormat = keyof typeof compressors
2424

2525
function switchCompressor(format: compressFormat): compressor {
26-
const f = compressors[format] || zlib[format + 'CompressSync']
27-
if (!f) {
28-
if (Object.prototype.hasOwnProperty.call(compressors, format))
29-
throw Error(`Could not get compressor: Please upgrade node.js or set your compressor function.`)
30-
throw Error(`Could not get compressor: Unknown compress format '${format}', please set your compressor function.`)
26+
if (!Object.prototype.hasOwnProperty.call(compressors, format)) {
27+
const f = zlib[format + 'CompressSync']
28+
if (!f) throw Error(`Could not get compressor: Unknown compress format '${format}', please set your compressor function.`)
29+
return f
3130
}
31+
const f = compressors[format]
32+
if (!f) throw Error(`Could not get compressor: Please upgrade node.js or set your compressor function.`)
3233
return f
3334
}
3435

0 commit comments

Comments
 (0)