compressing 1.9.0 → 1.10.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/README.md CHANGED
@@ -368,10 +368,11 @@ Although the API is streaming style(try to keep it handy), it still loads all da
368
368
 
369
369
  ## Contributors
370
370
 
371
- |[<img src="https://avatars.githubusercontent.com/u/456108?v=4" width="100px;"/><br/><sub><b>shaoshuai0102</b></sub>](https://github.com/shaoshuai0102)<br/>|[<img src="https://avatars.githubusercontent.com/u/156269?v=4" width="100px;"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>|[<img src="https://avatars.githubusercontent.com/u/360661?v=4" width="100px;"/><br/><sub><b>popomore</b></sub>](https://github.com/popomore)<br/>|[<img src="https://avatars.githubusercontent.com/u/9692408?v=4" width="100px;"/><br/><sub><b>DiamondYuan</b></sub>](https://github.com/DiamondYuan)<br/>|[<img src="https://avatars.githubusercontent.com/u/13938334?v=4" width="100px;"/><br/><sub><b>bytemain</b></sub>](https://github.com/bytemain)<br/>|[<img src="https://avatars.githubusercontent.com/u/8382136?v=4" width="100px;"/><br/><sub><b>Ryqsky</b></sub>](https://github.com/Ryqsky)<br/>|
371
+ |[<img src="https://avatars.githubusercontent.com/u/156269?v=4" width="100px;"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>|[<img src="https://avatars.githubusercontent.com/u/456108?v=4" width="100px;"/><br/><sub><b>shaoshuai0102</b></sub>](https://github.com/shaoshuai0102)<br/>|[<img src="https://avatars.githubusercontent.com/u/360661?v=4" width="100px;"/><br/><sub><b>popomore</b></sub>](https://github.com/popomore)<br/>|[<img src="https://avatars.githubusercontent.com/u/32174276?v=4" width="100px;"/><br/><sub><b>semantic-release-bot</b></sub>](https://github.com/semantic-release-bot)<br/>|[<img src="https://avatars.githubusercontent.com/u/9692408?v=4" width="100px;"/><br/><sub><b>DiamondYuan</b></sub>](https://github.com/DiamondYuan)<br/>|[<img src="https://avatars.githubusercontent.com/u/101238421?v=4" width="100px;"/><br/><sub><b>acyza</b></sub>](https://github.com/acyza)<br/>|
372
372
  | :---: | :---: | :---: | :---: | :---: | :---: |
373
- [<img src="https://avatars.githubusercontent.com/u/47357585?v=4" width="100px;"/><br/><sub><b>songhn233</b></sub>](https://github.com/songhn233)<br/>|[<img src="https://avatars.githubusercontent.com/u/9857273?v=4" width="100px;"/><br/><sub><b>ShadyZOZ</b></sub>](https://github.com/ShadyZOZ)<br/>
373
+ |[<img src="https://avatars.githubusercontent.com/u/13938334?v=4" width="100px;"/><br/><sub><b>bytemain</b></sub>](https://github.com/bytemain)<br/>|[<img src="https://avatars.githubusercontent.com/u/20432815?v=4" width="100px;"/><br/><sub><b>rickyes</b></sub>](https://github.com/rickyes)<br/>|[<img src="https://avatars.githubusercontent.com/u/8382136?v=4" width="100px;"/><br/><sub><b>Ryqsky</b></sub>](https://github.com/Ryqsky)<br/>|[<img src="https://avatars.githubusercontent.com/u/47357585?v=4" width="100px;"/><br/><sub><b>songhn233</b></sub>](https://github.com/songhn233)<br/>|[<img src="https://avatars.githubusercontent.com/u/160386?v=4" width="100px;"/><br/><sub><b>Infiltrator</b></sub>](https://github.com/Infiltrator)<br/>|[<img src="https://avatars.githubusercontent.com/u/13861843?v=4" width="100px;"/><br/><sub><b>ZeekoZhu</b></sub>](https://github.com/ZeekoZhu)<br/>|
374
+ [<img src="https://avatars.githubusercontent.com/u/6897780?v=4" width="100px;"/><br/><sub><b>killagu</b></sub>](https://github.com/killagu)<br/>|[<img src="https://avatars.githubusercontent.com/u/59508678?v=4" width="100px;"/><br/><sub><b>okaponta</b></sub>](https://github.com/okaponta)<br/>|[<img src="https://avatars.githubusercontent.com/u/9857273?v=4" width="100px;"/><br/><sub><b>ShadyZOZ</b></sub>](https://github.com/ShadyZOZ)<br/>
374
375
 
375
- This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Mon Jul 11 2022 08:28:25 GMT+0800`.
376
+ This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Thu Aug 03 2023 01:39:37 GMT+0800`.
376
377
 
377
378
  <!-- GITCONTRIBUTOR_END -->
package/lib/tar/stream.js CHANGED
@@ -75,12 +75,12 @@ class TarStream extends BaseStream {
75
75
  files.forEach(fileOrDir => {
76
76
  const newOpts = utils.clone(opts);
77
77
  if (opts.ignoreBase) {
78
- newOpts.relativePath = path.join(relativePath, fileOrDir);
78
+ newOpts.relativePath = path.posix.join(relativePath, fileOrDir);
79
79
  } else {
80
- newOpts.relativePath = path.join(relativePath, path.basename(entry), fileOrDir);
80
+ newOpts.relativePath = path.posix.join(relativePath, path.basename(entry), fileOrDir);
81
81
  }
82
82
  newOpts.ignoreBase = true;
83
- this.addEntry(path.join(entry, fileOrDir), newOpts);
83
+ this.addEntry(path.posix.join(entry, fileOrDir), newOpts);
84
84
  });
85
85
  this._onEntryFinish();
86
86
  });
package/lib/utils.js CHANGED
@@ -118,11 +118,20 @@ exports.makeUncompressFn = StreamClass => {
118
118
  entryCount++;
119
119
  pump(stream, fs.createWriteStream(fullpath, { mode: opts.mode || header.mode }), err => {
120
120
  if (err) return reject(err);
121
-
122
121
  successCount++;
123
122
  done();
124
123
  });
125
124
  });
125
+ } else if (header.type === 'symlink') {
126
+ // symlink
127
+ const src = path.join(destDir, header.name);
128
+ const target = path.resolve(path.dirname(src), header.linkname);
129
+ entryCount++;
130
+ fs.symlink(target, src, err => {
131
+ if (err) return reject(err);
132
+ successCount++;
133
+ stream.resume();
134
+ });
126
135
  } else { // directory
127
136
  mkdirp(path.join(destDir, header.name), err => {
128
137
  if (err) return reject(err);
@@ -139,12 +148,12 @@ exports.streamToBuffer = stream => {
139
148
  return new Promise((resolve, reject) => {
140
149
  const chunks = [];
141
150
  stream
142
- .on('readable', () => {
143
- let chunk;
144
- while ((chunk = stream.read())) chunks.push(chunk);
145
- })
146
- .on('end', () => resolve(Buffer.concat(chunks)))
147
- .on('error', err => reject(err));
151
+ .on('readable', () => {
152
+ let chunk;
153
+ while ((chunk = stream.read())) chunks.push(chunk);
154
+ })
155
+ .on('end', () => resolve(Buffer.concat(chunks)))
156
+ .on('error', err => reject(err));
148
157
  });
149
158
  };
150
159
 
@@ -56,8 +56,8 @@ class ZipUncompressStream extends UncompressBaseStream {
56
56
 
57
57
  if (sourceType === 'stream') {
58
58
  utils.streamToBuffer(opts.source)
59
- .then(buf => yauzl.fromBuffer(buf, yauzlOpts, this[YAUZL_CALLBACK]))
60
- .catch(e => this.emit('error', e));
59
+ .then(buf => yauzl.fromBuffer(buf, yauzlOpts, this[YAUZL_CALLBACK]))
60
+ .catch(e => this.emit('error', e));
61
61
  return;
62
62
  }
63
63
 
@@ -65,12 +65,12 @@ class ZipUncompressStream extends UncompressBaseStream {
65
65
  srcStream.unpipe(srcStream);
66
66
 
67
67
  utils.streamToBuffer(srcStream)
68
- .then(buf => {
69
- this._chunks.push(buf);
70
- buf = Buffer.concat(this._chunks);
71
- yauzl.fromBuffer(buf, yauzlOpts, this[YAUZL_CALLBACK]);
72
- })
73
- .catch(e => this.emit('error', e));
68
+ .then(buf => {
69
+ this._chunks.push(buf);
70
+ buf = Buffer.concat(this._chunks);
71
+ yauzl.fromBuffer(buf, yauzlOpts, this[YAUZL_CALLBACK]);
72
+ })
73
+ .catch(e => this.emit('error', e));
74
74
  });
75
75
  }
76
76
 
@@ -85,38 +85,38 @@ class ZipUncompressStream extends UncompressBaseStream {
85
85
  zipFile.readEntry();
86
86
 
87
87
  zipFile
88
- .on('entry', entry => {
89
- const mode = modeFromEntry(entry);
90
- // fileName is buffer by default because decodeStrings = false
91
- if (Buffer.isBuffer(entry.fileName)) {
92
- if (this._zipFileNameEncoding === 'utf8') {
93
- entry.fileName = entry.fileName.toString();
94
- } else {
95
- if (!iconv) {
96
- iconv = require('iconv-lite');
88
+ .on('entry', entry => {
89
+ const mode = modeFromEntry(entry);
90
+ // fileName is buffer by default because decodeStrings = false
91
+ if (Buffer.isBuffer(entry.fileName)) {
92
+ if (this._zipFileNameEncoding === 'utf8') {
93
+ entry.fileName = entry.fileName.toString();
94
+ } else {
95
+ if (!iconv) {
96
+ iconv = require('iconv-lite');
97
+ }
98
+ entry.fileName = iconv.decode(entry.fileName, this._zipFileNameEncoding);
97
99
  }
98
- entry.fileName = iconv.decode(entry.fileName, this._zipFileNameEncoding);
99
100
  }
100
- }
101
- // directory file names end with '/'
102
- const type = /\/$/.test(entry.fileName) ? 'directory' : 'file';
103
- const name = entry.fileName = this[STRIP_NAME](entry.fileName, type);
104
-
105
- const header = { name, type, yauzl: entry, mode };
106
-
107
- if (type === 'file') {
108
- zipFile.openReadStream(entry, (err, readStream) => {
109
- if (err) return this.emit('error', err);
110
- this.emit('entry', header, readStream, next);
111
- });
112
- } else { // directory
113
- const placeholder = new stream.Readable({ read() {} });
114
- this.emit('entry', header, placeholder, next);
115
- setImmediate(() => placeholder.emit('end'));
116
- }
117
- })
118
- .on('end', () => this.emit('finish'))
119
- .on('error', err => this.emit('error', err));
101
+ // directory file names end with '/'
102
+ const type = /\/$/.test(entry.fileName) ? 'directory' : 'file';
103
+ const name = entry.fileName = this[STRIP_NAME](entry.fileName, type);
104
+
105
+ const header = { name, type, yauzl: entry, mode };
106
+
107
+ if (type === 'file') {
108
+ zipFile.openReadStream(entry, (err, readStream) => {
109
+ if (err) return this.emit('error', err);
110
+ this.emit('entry', header, readStream, next);
111
+ });
112
+ } else { // directory
113
+ const placeholder = new stream.Readable({ read() {} });
114
+ this.emit('entry', header, placeholder, next);
115
+ setImmediate(() => placeholder.emit('end'));
116
+ }
117
+ })
118
+ .on('end', () => this.emit('finish'))
119
+ .on('error', err => this.emit('error', err));
120
120
 
121
121
  function next() {
122
122
  zipFile.readEntry();
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "compressing",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "Everything you need for compressing and uncompressing",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "contributor": "git-contributor",
8
8
  "ts-test": "tsc -p ./test/fixtures/types/tsconfig.json",
9
- "test": "egg-bin test --espower=false --full-trace && npm run ts-test",
10
- "cov": "egg-bin cov --espower=false",
9
+ "test": "egg-bin test --ts false && npm run ts-test",
10
+ "cov": "egg-bin cov --ts false",
11
11
  "lint-fix": "eslint . --fix",
12
12
  "lint": "eslint .",
13
13
  "ci": "npm run lint && npm run ts-test && npm run cov"
@@ -50,17 +50,16 @@
50
50
  "yazl": "^2.4.2"
51
51
  },
52
52
  "devDependencies": {
53
- "@types/mocha": "^5.2.5",
54
- "@types/node": "^10.12.9",
53
+ "@types/mocha": "10",
54
+ "@types/node": "20",
55
55
  "dir-compare": "^1.3.0",
56
- "egg-bin": "4",
57
- "eslint": "^3.10.2",
58
- "eslint-config-egg": "^3.2.0",
59
- "git-contributor": "^1.1.0",
56
+ "egg-bin": "6",
57
+ "eslint": "8",
58
+ "eslint-config-egg": "12",
59
+ "git-contributor": "2",
60
60
  "mm": "^2.0.0",
61
61
  "mz-modules": "^2.1.0",
62
- "rimraf": "^2.6.2",
63
- "typescript": "^3.1.6",
62
+ "typescript": "5",
64
63
  "uuid": "^3.0.1"
65
64
  },
66
65
  "engines": {