bestzip 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.js CHANGED
@@ -10,11 +10,21 @@ var argv = require("yargs")
10
10
  describe: "Force use of node.js or native zip methods",
11
11
  choices: ["node", "native"],
12
12
  })
13
+ .option("level", {
14
+ describe: "Level of compression",
15
+ type: "number",
16
+ default: -1,
17
+ })
13
18
  .demand(2).argv;
14
19
 
15
20
  var destination = argv._.shift();
16
21
  var source = argv._;
17
22
 
23
+ if (argv.level < -1 || argv.level > 9) {
24
+ console.error("Invalid compression level, must be >= 0 and <= 9");
25
+ process.exit(1);
26
+ }
27
+
18
28
  console.log("Writing %s to %s...", source.join(", "), destination);
19
29
 
20
30
  if (argv.force === "node") {
@@ -26,7 +36,8 @@ if (argv.force === "node") {
26
36
  zip({
27
37
  source: source,
28
38
  destination: destination,
29
- verbose: argv.verbose,
39
+ verbose: !!argv.verbose,
40
+ level: argv.level,
30
41
  })
31
42
  .then(function () {
32
43
  console.log("zipped!");
package/lib/bestzip.js CHANGED
@@ -71,6 +71,15 @@ const nativeZip = (options) =>
71
71
  const args = ["--quiet", "--recurse-paths", options.destination].concat(
72
72
  sources
73
73
  );
74
+ if (
75
+ typeof options.level == "number" &&
76
+ !isNaN(options.level) &&
77
+ options.level >= 0 &&
78
+ options.level <= 9
79
+ ) {
80
+ args.splice(0, 0, "-" + options.level.toString());
81
+ }
82
+
74
83
  const zipProcess = cp.spawn(command, args, {
75
84
  stdio: "inherit",
76
85
  cwd,
@@ -99,7 +108,9 @@ const nodeZip = (options) =>
99
108
  new Promise((resolve, reject) => {
100
109
  const cwd = options.cwd || process.cwd();
101
110
  const output = fs.createWriteStream(path.resolve(cwd, options.destination));
102
- const archive = archiver("zip");
111
+ const archive = archiver("zip", {
112
+ zlib: { level: options.level },
113
+ });
103
114
 
104
115
  output.on("close", resolve);
105
116
  archive.on("error", reject);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bestzip",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "Uses OS zip command if avaliable (for better performance and speed) or node.js version if there is no system command avaliable. Can be called via node or command line.",
5
5
  "main": "lib/bestzip.js",
6
6
  "bin": {
@@ -17,7 +17,10 @@
17
17
  },
18
18
  "author": "Nathan Friedly - http://nfriedly.com/",
19
19
  "license": "MIT",
20
- "repository": "git@github.com:nfriedly/node-bestzip.git",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+ssh://git@github.com/nfriedly/node-bestzip.git"
23
+ },
21
24
  "homepage": "https://github.com/nfriedly/node-bestzip",
22
25
  "files": [
23
26
  "bin/cli.js",
@@ -36,7 +39,7 @@
36
39
  "eslint": "^7.22.0",
37
40
  "eslint-config-prettier": "^8.1.0",
38
41
  "eslint-plugin-prettier": "^3.3.1",
39
- "jest": "^26.6.3",
42
+ "jest": "^29.7.0",
40
43
  "klaw-sync": "^6.0.0",
41
44
  "prettier": "^2.2.1",
42
45
  "regenerator-runtime": "^0.13.7",
package/readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # bestzip
2
2
 
3
- [![Build status](https://travis-ci.org/nfriedly/node-bestzip.svg?branch=master)](https://travis-ci.org/nfriedly/node-bestzip)
3
+ [![tests](https://github.com/nfriedly/node-bestzip/actions/workflows/ci.yml/badge.svg)](https://github.com/nfriedly/node-bestzip/actions/workflows/ci.yml)
4
4
  [![npm version](https://badge.fury.io/js/bestzip.svg)](https://www.npmjs.com/package/bestzip)
5
5
  [![npm downloads](https://img.shields.io/npm/dm/bestzip)](https://www.npmjs.com/package/bestzip)
6
6
 
@@ -59,6 +59,7 @@ zip({
59
59
  * `source`: Path or paths to files and folders to include in the zip file. String or Array of Strings.
60
60
  * `destination`: Path to generated .zip file.
61
61
  * `cwd`: Set the Current Working Directory that source and destination paths are relative to. Defaults to `process.cwd()`
62
+ * `level`: Set the level of compression. (Number 0-9, with 0 being no compression and 9 being the most compressed.)
62
63
 
63
64
  ## How to control the directory structure
64
65