Last change
on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
476 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | const fs = require("fs");
|
---|
| 2 | const zlib = require("zlib");
|
---|
| 3 |
|
---|
| 4 | const src = process.argv[2];
|
---|
| 5 | if (!src || !src.length) {
|
---|
| 6 | process.stderr.write("missing input file");
|
---|
| 7 | process.exit(1);
|
---|
| 8 | }
|
---|
| 9 |
|
---|
| 10 | try {
|
---|
| 11 | const raw = fs.readFileSync(src);
|
---|
| 12 | const encoded = zlib
|
---|
| 13 | .deflateSync(Buffer.from(raw), { level: zlib.constants.Z_BEST_COMPRESSION })
|
---|
| 14 | .toString("base64");
|
---|
| 15 | process.stdout.write(encoded);
|
---|
| 16 | } catch (e) {
|
---|
| 17 | process.stderr.write(`error encoding: ${e.message}`);
|
---|
| 18 | process.exit(1);
|
---|
| 19 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.