compressing 1.5.1 → 1.6.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/History.md CHANGED
@@ -1,4 +1,13 @@
1
1
 
2
+ 1.6.0 / 2022-06-13
3
+ ==================
4
+
5
+ **features**
6
+ * [[`bd8ef44`](http://github.com/node-modules/compressing/commit/bd8ef44ade2f4b93d41ff2f78d6f17902d965798)] - feat: unzip should keep file mode (#68) (Artin <<lengthmin@gmail.com>>)
7
+
8
+ **others**
9
+ * [[`592e518`](http://github.com/node-modules/compressing/commit/592e5180dfbdbc6cb1becd1baf6a007ce7b7cd39)] - Create codeql-analysis.yml (fengmk2 <<fengmk2@gmail.com>>)
10
+
2
11
  1.5.1 / 2020-05-11
3
12
  ==================
4
13
 
package/README.md CHANGED
@@ -1,22 +1,13 @@
1
1
  # compressing
2
2
 
3
3
  [![NPM version][npm-image]][npm-url]
4
- [![build status][travis-image]][travis-url]
5
4
  [![Test coverage][codecov-image]][codecov-url]
6
- [![David deps][david-image]][david-url]
7
- [![Known Vulnerabilities][snyk-image]][snyk-url]
8
5
  [![npm download][download-image]][download-url]
9
6
 
10
7
  [npm-image]: https://img.shields.io/npm/v/compressing.svg?style=flat-square
11
8
  [npm-url]: https://npmjs.org/package/compressing
12
- [travis-image]: https://img.shields.io/travis/node-modules/compressing.svg?style=flat-square
13
- [travis-url]: https://travis-ci.org/node-modules/compressing
14
9
  [codecov-image]: https://codecov.io/gh/node-modules/compressing/branch/master/graph/badge.svg
15
10
  [codecov-url]: https://codecov.io/gh/node-modules/compressing
16
- [david-image]: https://img.shields.io/david/node-modules/compressing.svg?style=flat-square
17
- [david-url]: https://david-dm.org/node-modules/compressing
18
- [snyk-image]: https://snyk.io/test/npm/compressing/badge.svg?style=flat-square
19
- [snyk-url]: https://snyk.io/test/npm/compressing
20
11
  [download-image]: https://img.shields.io/npm/dm/compressing.svg?style=flat-square
21
12
  [download-url]: https://npmjs.org/package/compressing
22
13
 
@@ -88,7 +79,6 @@ const destStream = fs.createWriteStream('path/to/destination.gz');
88
79
  pump(sourceStream, gzipStream, destStream, handleError);
89
80
  ```
90
81
 
91
-
92
82
  ### Compress a dir
93
83
 
94
84
  Use tar as an example, tgz and zip is same as gzip.
@@ -167,8 +157,7 @@ compressing.tgz.uncompress(stream, 'path/to/destination/dir')
167
157
  .catch(handleError);
168
158
  ```
169
159
 
170
- **Note: tar, tgz and zip have the same uncompressing API as above: destination should be a path of a directory, while that of gzip is slightly different: destination must be a file or filestream.**
171
-
160
+ __Note: tar, tgz and zip have the same uncompressing API as above: destination should be a path of a directory, while that of gzip is slightly different: destination must be a file or filestream.__
172
161
 
173
162
  And working with urllib is super easy. Let's download a tgz file and uncompress to a directory:
174
163
 
@@ -280,7 +269,7 @@ Use this API to uncompress a file. This is a convenient method, which wraps Unco
280
269
  Params
281
270
 
282
271
  - source {String|Buffer|Stream} - source to be uncompressed
283
- - dest {String|Stream} - uncompressing destination. When uncompressing tar, tgz and zip, it should be a directory path (eg. `/path/to/xx`). **When uncompressing gzip, it should be a file path or a writable stream.**
272
+ - dest {String|Stream} - uncompressing destination. When uncompressing tar, tgz and zip, it should be a directory path (eg. `/path/to/xx`). __When uncompressing gzip, it should be a file path or a writable stream.__
284
273
  - opts {Object} - usually you don't need it
285
274
  - opts.zipFileNameEncoding {String} - Only work on zip format, default is 'utf8'.
286
275
  Major non-UTF8 encodings by languages:
@@ -374,4 +363,15 @@ Due to the design of the .zip file format, it's impossible to interpret a .zip f
374
363
 
375
364
  Although the API is streaming style(try to keep it handy), it still loads all data into memory.
376
365
 
377
- https://github.com/thejoshwolfe/yauzl#no-streaming-unzip-api
366
+ <https://github.com/thejoshwolfe/yauzl#no-streaming-unzip-api>
367
+ <!-- GITCONTRIBUTOR_START -->
368
+
369
+ ## Contributors
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/>|
372
+ | :---: | :---: | :---: | :---: | :---: | :---: |
373
+ [<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
+ This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Mon Jun 13 2022 13:26:08 GMT+0800`.
376
+
377
+ <!-- GITCONTRIBUTOR_END -->
package/index.d.ts CHANGED
@@ -15,6 +15,12 @@ interface streamHeader {
15
15
  name: string
16
16
  }
17
17
 
18
+ interface streamHeaderWithMode {
19
+ type: 'file' | 'directory',
20
+ name: string
21
+ mode: number
22
+ }
23
+
18
24
  export namespace gzip {
19
25
 
20
26
  function compressFile(source: sourceType, dest: destType, opts?: any): Promise<void>
@@ -79,7 +85,7 @@ export namespace tar {
79
85
  });
80
86
 
81
87
  on(event: string, listener: (...args: any[]) => void): this
82
- on(event: 'entry', listener: (header: streamHeader, stream: WriteStream, next: () => void) => void): this
88
+ on(event: 'entry', listener: (header: streamHeaderWithMode, stream: WriteStream, next: () => void) => void): this
83
89
  on(event: 'finish', listener: () => void): this
84
90
  on(event: 'error', listener: (err: Error) => void): this
85
91
 
@@ -124,7 +130,7 @@ export namespace tgz {
124
130
  });
125
131
 
126
132
  on(event: string, listener: (...args: any[]) => void): this
127
- on(event: 'entry', listener: (header: streamHeader, stream: WriteStream, next: () => void) => void): this
133
+ on(event: 'entry', listener: (header: streamHeaderWithMode, stream: WriteStream, next: () => void) => void): this
128
134
  on(event: 'finish', listener: () => void): this
129
135
  on(event: 'error', listener: (err: Error) => void): this
130
136
 
@@ -177,7 +183,7 @@ export namespace zip {
177
183
  });
178
184
 
179
185
  on(event: string, listener: (...args: any[]) => void): this
180
- on(event: 'entry', listener: (header: streamHeader, stream: WriteStream, next: () => void) => void): this
186
+ on(event: 'entry', listener: (header: streamHeaderWithMode, stream: WriteStream, next: () => void) => void): this
181
187
  on(event: 'finish', listener: () => void): this
182
188
  on(event: 'error', listener: (err: Error) => void): this
183
189
 
@@ -18,6 +18,15 @@ const STRIP_NAME = Symbol('ZipUncompressStream#stripName');
18
18
  // - support "absolute path"
19
19
  const DEFAULTS = { lazyEntries: true, decodeStrings: false };
20
20
 
21
+ // from: https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/node/zip.ts#L51
22
+ function modeFromEntry(entry) {
23
+ const attr = entry.externalFileAttributes >> 16 || 33188;
24
+
25
+ return [ 448 /* S_IRWXU */, 56 /* S_IRWXG */, 7 /* S_IRWXO */ ]
26
+ .map(mask => attr & mask)
27
+ .reduce((a, b) => a + b, attr & 61440 /* S_IFMT */);
28
+ }
29
+
21
30
  class ZipUncompressStream extends UncompressBaseStream {
22
31
  constructor(opts) {
23
32
  opts = opts || {};
@@ -77,6 +86,7 @@ class ZipUncompressStream extends UncompressBaseStream {
77
86
 
78
87
  zipFile
79
88
  .on('entry', entry => {
89
+ const mode = modeFromEntry(entry);
80
90
  // fileName is buffer by default because decodeStrings = false
81
91
  if (Buffer.isBuffer(entry.fileName)) {
82
92
  if (this._zipFileNameEncoding === 'utf8') {
@@ -92,7 +102,7 @@ class ZipUncompressStream extends UncompressBaseStream {
92
102
  const type = /\/$/.test(entry.fileName) ? 'directory' : 'file';
93
103
  const name = entry.fileName = this[STRIP_NAME](entry.fileName, type);
94
104
 
95
- const header = { name, type, yauzl: entry };
105
+ const header = { name, type, yauzl: entry, mode };
96
106
 
97
107
  if (type === 'file') {
98
108
  zipFile.openReadStream(entry, (err, readStream) => {
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "compressing",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
4
4
  "description": "Everything you need for compressing and uncompressing",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
+ "contributor": "git-contributor",
7
8
  "ts-test": "tsc -p ./test/fixtures/types/tsconfig.json",
8
9
  "test": "egg-bin test && npm run ts-test",
9
10
  "cov": "egg-bin cov",
@@ -55,6 +56,7 @@
55
56
  "egg-ci": "^1.8.0",
56
57
  "eslint": "^3.10.2",
57
58
  "eslint-config-egg": "^3.2.0",
59
+ "git-contributor": "^1.1.0",
58
60
  "mm": "^2.0.0",
59
61
  "mz-modules": "^2.1.0",
60
62
  "power-assert": "^1.4.2",