archiver-node 8.0.3 → 8.0.4
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/cjs/Archiver.js +771 -679
- package/cjs/archivers/JsonArchive.js +35 -42
- package/cjs/archivers/TarArchive.js +35 -42
- package/cjs/archivers/ZipArchive.js +35 -42
- package/cjs/error.js +10 -38
- package/cjs/lazystream.js +97 -51
- package/cjs/plugins/json.js +106 -102
- package/cjs/plugins/tar.js +128 -131
- package/cjs/plugins/zip.js +90 -95
- package/cjs/readdir-glob.js +382 -0
- package/cjs/utils.js +27 -55
- package/package.json +5 -3
package/cjs/utils.js
CHANGED
|
@@ -1,54 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var utils_exports = {};
|
|
29
|
-
__export(utils_exports, {
|
|
30
|
-
collectStream: () => collectStream,
|
|
31
|
-
dateify: () => dateify,
|
|
32
|
-
normalizeInputSource: () => normalizeInputSource,
|
|
33
|
-
sanitizePath: () => sanitizePath,
|
|
34
|
-
trailingSlashIt: () => trailingSlashIt
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
35
5
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
6
|
+
exports.collectStream = collectStream;
|
|
7
|
+
exports.dateify = dateify;
|
|
8
|
+
exports.normalizeInputSource = normalizeInputSource;
|
|
9
|
+
exports.sanitizePath = sanitizePath;
|
|
10
|
+
exports.trailingSlashIt = trailingSlashIt;
|
|
11
|
+
var _normalizePath = _interopRequireDefault(require("normalize-path"));
|
|
12
|
+
var _readableStream = require("readable-stream");
|
|
13
|
+
var _isStream = require("is-stream");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
40
15
|
function collectStream(source, callback) {
|
|
41
16
|
var collection = [];
|
|
42
17
|
var size = 0;
|
|
43
18
|
source.on("error", callback);
|
|
44
|
-
source.on("data", function(chunk) {
|
|
19
|
+
source.on("data", function (chunk) {
|
|
45
20
|
collection.push(chunk);
|
|
46
21
|
size += chunk.length;
|
|
47
22
|
});
|
|
48
|
-
source.on("end", function() {
|
|
23
|
+
source.on("end", function () {
|
|
49
24
|
var buf = Buffer.alloc(size);
|
|
50
25
|
var offset = 0;
|
|
51
|
-
collection.forEach(function(data) {
|
|
26
|
+
collection.forEach(function (data) {
|
|
52
27
|
data.copy(buf, offset);
|
|
53
28
|
offset += data.length;
|
|
54
29
|
});
|
|
@@ -56,13 +31,13 @@ function collectStream(source, callback) {
|
|
|
56
31
|
});
|
|
57
32
|
}
|
|
58
33
|
function dateify(dateish) {
|
|
59
|
-
dateish = dateish ||
|
|
34
|
+
dateish = dateish || new Date();
|
|
60
35
|
if (dateish instanceof Date) {
|
|
61
36
|
dateish = dateish;
|
|
62
37
|
} else if (typeof dateish === "string") {
|
|
63
38
|
dateish = new Date(dateish);
|
|
64
39
|
} else {
|
|
65
|
-
dateish =
|
|
40
|
+
dateish = new Date();
|
|
66
41
|
}
|
|
67
42
|
return dateish;
|
|
68
43
|
}
|
|
@@ -71,22 +46,19 @@ function normalizeInputSource(source) {
|
|
|
71
46
|
return Buffer.alloc(0);
|
|
72
47
|
} else if (typeof source === "string") {
|
|
73
48
|
return Buffer.from(source);
|
|
74
|
-
} else if ((0,
|
|
75
|
-
|
|
49
|
+
} else if ((0, _isStream.isStream)(source, {
|
|
50
|
+
canOpen: false
|
|
51
|
+
})) {
|
|
52
|
+
// Always pipe through a PassThrough stream to guarantee pausing the stream if it's already flowing,
|
|
53
|
+
// since it will only be processed in a (distant) future iteration of the event loop, and will lose
|
|
54
|
+
// data if already flowing now.
|
|
55
|
+
return source.pipe(new _readableStream.PassThrough());
|
|
76
56
|
}
|
|
77
57
|
return source;
|
|
78
58
|
}
|
|
79
59
|
function sanitizePath(filepath) {
|
|
80
|
-
return (0,
|
|
60
|
+
return (0, _normalizePath["default"])(filepath, false).replace(/^\w+:/, "").replace(/^(\.\.\/|\/)+/, "");
|
|
81
61
|
}
|
|
82
62
|
function trailingSlashIt(str) {
|
|
83
63
|
return str.slice(-1) !== "/" ? str + "/" : str;
|
|
84
|
-
}
|
|
85
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
-
0 && (module.exports = {
|
|
87
|
-
collectStream,
|
|
88
|
-
dateify,
|
|
89
|
-
normalizeInputSource,
|
|
90
|
-
sanitizePath,
|
|
91
|
-
trailingSlashIt
|
|
92
|
-
});
|
|
64
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "archiver-node",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.4",
|
|
4
4
|
"description": "a streaming interface for archive generation",
|
|
5
5
|
"homepage": "https://github.com/catamphetamine/node-archiver",
|
|
6
6
|
"author": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build:clean": "rimraf cjs",
|
|
39
|
-
"build:cjs": "
|
|
39
|
+
"build:cjs": "babel lib --out-dir cjs",
|
|
40
40
|
"build:cjs:package.json": "node scripts/create-commonjs-package-json.js",
|
|
41
41
|
"build": "npm-run-all build:clean build:cjs build:cjs:package.json",
|
|
42
42
|
"test": "mocha --reporter dot",
|
|
@@ -54,9 +54,11 @@
|
|
|
54
54
|
"zip-stream": "^7.0.2"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
+
"@babel/cli": "^7.28.6",
|
|
58
|
+
"@babel/core": "^7.29.0",
|
|
59
|
+
"@babel/preset-env": "^7.29.0",
|
|
57
60
|
"archiver-jsdoc-theme": "1.1.3",
|
|
58
61
|
"chai": "4.5.0",
|
|
59
|
-
"esbuild": "^0.27.3",
|
|
60
62
|
"jsdoc": "4.0.4",
|
|
61
63
|
"mkdirp": "3.0.1",
|
|
62
64
|
"mocha": "10.8.2",
|