redzip 4.0.1 → 4.2.0

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/ChangeLog CHANGED
@@ -1,3 +1,19 @@
1
+ 2026.02.24, v4.2.0
2
+
3
+ feature:
4
+ - 2c7e9cc redzip: write: date: directory (coderaiser/cloudcmd#457)
5
+ - de68a82 redzip: write: date: add (coderaiser/cloudcmd#457)
6
+
7
+ 2026.02.21, v4.1.0
8
+
9
+ feature:
10
+ - 7ccfd80 redzip: write: date: add (coderaiser/cloudcmd/#457)
11
+ - 72df84a redzip: redlint v6.1.1
12
+ - 5751676 redzip: putout v42.0.12
13
+ - 25589de redzip: madrun v13.0.0
14
+ - 71c2796 redzip: eslint-plugin-putout v31.0.1
15
+ - b3ab64e redzip: eslint v10.0.1
16
+
1
17
  2026.02.13, v4.0.1
2
18
 
3
19
  feature:
package/README.md CHANGED
@@ -150,6 +150,7 @@ When you need to save `string`, or `Buffer` use [Readable.from](https://nodejs.o
150
150
  - **options** - `object` can contain:
151
151
  - `unzip` - unzip file content before writing
152
152
  - `mode` - set permissions mode (optional)
153
+ - `date` - date of modication
153
154
 
154
155
  #### Example
155
156
 
@@ -15,6 +15,7 @@ import {
15
15
  unlink as _unlink,
16
16
  lstat,
17
17
  opendir,
18
+ utimes,
18
19
  } from 'node:fs/promises';
19
20
  import readify from 'readify';
20
21
  import trammel from 'trammel';
@@ -26,18 +27,33 @@ const winNotDir = (e) => e?.code === 'ENOENT';
26
27
 
27
28
  const {assign} = Object;
28
29
 
30
+ const maybeSetDate = async (path, date) => {
31
+ if (!date)
32
+ return;
33
+
34
+ await tryToCatch(utimes, path, date, date);
35
+ };
36
+
29
37
  export const write = async (outerPath, innerPath, readStream, options = {}) => {
30
- const {unzip, mode} = options;
38
+ const {
39
+ unzip,
40
+ mode,
41
+ date,
42
+ } = options;
31
43
 
32
44
  if (!readStream) {
33
45
  await mkdir(outerPath, {
34
46
  recursive: true,
35
47
  mode,
36
48
  });
49
+ await maybeSetDate(outerPath, date);
50
+
37
51
  return;
38
52
  }
39
53
 
40
- await mkdir(dirname(outerPath), {
54
+ const dirPath = dirname(outerPath);
55
+
56
+ await mkdir(dirPath, {
41
57
  recursive: true,
42
58
  });
43
59
 
@@ -49,6 +65,9 @@ export const write = async (outerPath, innerPath, readStream, options = {}) => {
49
65
  return await pipe([readStream, createGunzip(), writeStream]);
50
66
 
51
67
  await pipe([readStream, writeStream]);
68
+
69
+ await maybeSetDate(outerPath, date);
70
+ await maybeSetDate(dirPath, date);
52
71
  };
53
72
 
54
73
  export const readSize = async (outerPath, innerPath, options) => {
@@ -60,6 +79,7 @@ export const remove = async (outerPath, overrides = {}) => {
60
79
  rmdir = _rmdir,
61
80
  unlink = _unlink,
62
81
  } = overrides;
82
+
63
83
  const [error] = await tryToCatch(rmdir, outerPath);
64
84
 
65
85
  if (!error)
@@ -25,6 +25,7 @@ const end = promisify((zipfile, fn) => {
25
25
 
26
26
  export default async (outerPath, innerPath, stream, options = {}) => {
27
27
  const {
28
+ date,
28
29
  rename = _rename,
29
30
  unzip,
30
31
  remove,
@@ -42,6 +43,7 @@ export default async (outerPath, innerPath, stream, options = {}) => {
42
43
 
43
44
  const createArchive = Promise.all([
44
45
  update(outerPath, innerPath, readStream, zipfile, {
46
+ date,
45
47
  remove,
46
48
  }),
47
49
  replace(outerPath, tmpName, outputStream, {
@@ -65,14 +67,16 @@ export default async (outerPath, innerPath, stream, options = {}) => {
65
67
  }
66
68
  };
67
69
 
68
- async function update(outerPath, innerPath, stream, zipfile, {remove}) {
70
+ async function update(outerPath, innerPath, stream, zipfile, {remove, date}) {
69
71
  const shortPath = innerPath.slice(1);
70
72
 
71
73
  if (!remove && stream)
72
74
  zipfile.addReadStream(stream, shortPath);
73
75
 
74
76
  if (!remove && !stream)
75
- zipfile.addEmptyDirectory(shortPath);
77
+ zipfile.addEmptyDirectory(shortPath, {
78
+ mtime: date,
79
+ });
76
80
 
77
81
  let count = 0;
78
82
 
@@ -85,7 +89,9 @@ async function update(outerPath, innerPath, stream, zipfile, {remove}) {
85
89
 
86
90
  if (path.isFile()) {
87
91
  stream = await path.openReadStream();
88
- zipfile.addReadStream(stream, entry.fileName);
92
+ zipfile.addReadStream(stream, entry.fileName, {
93
+ mtime: date,
94
+ });
89
95
  continue;
90
96
  }
91
97
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redzip",
3
- "version": "4.0.1",
3
+ "version": "4.2.0",
4
4
  "type": "module",
5
5
  "main": "lib/redzip.js",
6
6
  "description": "work with files inside archives like with regular files",
@@ -41,15 +41,15 @@
41
41
  "devDependencies": {
42
42
  "@iocmd/wait": "^2.1.0",
43
43
  "c8": "^10.1.2",
44
- "eslint": "^9.9.0",
45
- "eslint-plugin-putout": "^30.0.1",
46
- "madrun": "^12.1.3",
44
+ "eslint": "^10.0.1",
45
+ "eslint-plugin-putout": "^31.0.1",
46
+ "madrun": "^13.0.0",
47
47
  "memfs": "^4.2.1",
48
48
  "mock-fs": "^5.0.0",
49
49
  "nodemon": "^3.0.1",
50
50
  "pullout": "^5.0.1",
51
- "putout": "^41.15.0",
52
- "redlint": "^5.4.0",
51
+ "putout": "^42.0.12",
52
+ "redlint": "^6.1.1",
53
53
  "supertape": "^12.2.0"
54
54
  },
55
55
  "keywords": [