Comparing version 1.0.2 to 1.0.3
@@ -9,2 +9,8 @@ All notable changes to this project will be documented in this file. | ||
## [1.0.3] - 2021-08-13 | ||
### Fixed | ||
- crash when compressing empty files | ||
### Dev | ||
- dev dep upgrade | ||
## [1.0.2] - 2021-07-09 | ||
@@ -11,0 +17,0 @@ ### Changed |
@@ -135,16 +135,27 @@ #!/usr/bin/env node | ||
let p = readFile(file) | ||
.then(buffer => brotli_1.compress(buffer, { | ||
mode: modes.indexOf(argv.mode), | ||
quality: argv.quality, | ||
lgwin: argv.lgwin, | ||
})) | ||
.then((compressed) => { | ||
.then(buffer => { | ||
if (!buffer.length) { | ||
return { | ||
sourceLength: 0, | ||
compressed: null, | ||
}; | ||
} | ||
return { | ||
sourceLength: buffer.length, | ||
compressed: brotli_1.compress(buffer, { | ||
mode: modes.indexOf(argv.mode), | ||
quality: argv.quality, | ||
lgwin: argv.lgwin, | ||
}), | ||
}; | ||
}) | ||
.then(async ({ sourceLength, compressed }) => { | ||
if (printToStdOut) { | ||
process.stdout.write(compressed); | ||
process.stdout.write(compressed !== null && compressed !== void 0 ? compressed : ""); | ||
return; | ||
} | ||
if (compressed == null) { | ||
if (sourceLength && compressed == null) { | ||
throw new TypeError("Empty response returned from brotli"); | ||
} | ||
return writeFile(argv.br ? file + ".br" : file, compressed); | ||
return writeFile(argv.br ? file + ".br" : file, compressed !== null && compressed !== void 0 ? compressed : ""); | ||
}); | ||
@@ -151,0 +162,0 @@ if (!argv.bail) { |
{ | ||
"name": "brotli-cli", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"repository": "git@github.com:dzek69/brotli-cli.git", | ||
@@ -61,2 +61,2 @@ "author": "Jacek Nowacki", | ||
} | ||
} | ||
} |
@@ -33,4 +33,3 @@ #!/usr/bin/env node | ||
// yargs needs that unused expression | ||
// eslint-disable-next-line max-len | ||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-magic-numbers | ||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions,@typescript-eslint/no-magic-numbers | ||
yargs(process.argv.slice(2)) | ||
@@ -178,18 +177,29 @@ .scriptName("brotli-cli") | ||
let p = readFile(file) | ||
.then(buffer => compress(buffer, { | ||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers | ||
mode: modes.indexOf(argv.mode) as 0 | 1 | 2, | ||
quality: argv.quality as Quality, | ||
lgwin: argv.lgwin, | ||
})) | ||
.then((compressed) => { | ||
.then(buffer => { | ||
if (!buffer.length) { | ||
return { | ||
sourceLength: 0, | ||
compressed: null, | ||
}; | ||
} | ||
return { | ||
sourceLength: buffer.length, | ||
compressed: compress(buffer, { | ||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers | ||
mode: modes.indexOf(argv.mode) as 0 | 1 | 2, | ||
quality: argv.quality as Quality, | ||
lgwin: argv.lgwin, | ||
}), | ||
}; | ||
}) | ||
.then(async ({ sourceLength, compressed }) => { | ||
if (printToStdOut) { | ||
process.stdout.write(compressed); | ||
process.stdout.write(compressed ?? ""); | ||
return; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
if (compressed == null) { | ||
if (sourceLength && compressed == null) { | ||
throw new TypeError("Empty response returned from brotli"); | ||
} | ||
return writeFile(argv.br ? file + ".br" : file, compressed); | ||
return writeFile(argv.br ? file + ".br" : file, compressed ?? ""); | ||
}); | ||
@@ -196,0 +206,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
211826
3066