bestzip 2.2.0 → 2.2.1
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 +12 -1
- package/lib/bestzip.js +12 -1
- package/package.json +1 -1
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.
|
|
3
|
+
"version": "2.2.1",
|
|
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": {
|