compressing
Advanced tools
Comparing version 1.5.1 to 1.6.0
1.6.0 / 2022-06-13 | ||
================== | ||
**features** | ||
* [[`bd8ef44`](http://github.com/node-modules/compressing/commit/bd8ef44ade2f4b93d41ff2f78d6f17902d965798)] - feat: unzip should keep file mode (#68) (Artin <<lengthmin@gmail.com>>) | ||
**others** | ||
* [[`592e518`](http://github.com/node-modules/compressing/commit/592e5180dfbdbc6cb1becd1baf6a007ce7b7cd39)] - Create codeql-analysis.yml (fengmk2 <<fengmk2@gmail.com>>) | ||
1.5.1 / 2020-05-11 | ||
@@ -3,0 +12,0 @@ ================== |
@@ -18,2 +18,8 @@ import { ReadStream, WriteStream } from 'fs' | ||
interface streamHeaderWithMode { | ||
type: 'file' | 'directory', | ||
name: string | ||
mode: number | ||
} | ||
export namespace gzip { | ||
@@ -83,3 +89,3 @@ | ||
on(event: string, listener: (...args: any[]) => void): this | ||
on(event: 'entry', listener: (header: streamHeader, stream: WriteStream, next: () => void) => void): this | ||
on(event: 'entry', listener: (header: streamHeaderWithMode, stream: WriteStream, next: () => void) => void): this | ||
on(event: 'finish', listener: () => void): this | ||
@@ -129,3 +135,3 @@ on(event: 'error', listener: (err: Error) => void): this | ||
on(event: string, listener: (...args: any[]) => void): this | ||
on(event: 'entry', listener: (header: streamHeader, stream: WriteStream, next: () => void) => void): this | ||
on(event: 'entry', listener: (header: streamHeaderWithMode, stream: WriteStream, next: () => void) => void): this | ||
on(event: 'finish', listener: () => void): this | ||
@@ -183,3 +189,3 @@ on(event: 'error', listener: (err: Error) => void): this | ||
on(event: string, listener: (...args: any[]) => void): this | ||
on(event: 'entry', listener: (header: streamHeader, stream: WriteStream, next: () => void) => void): this | ||
on(event: 'entry', listener: (header: streamHeaderWithMode, stream: WriteStream, next: () => void) => void): this | ||
on(event: 'finish', listener: () => void): this | ||
@@ -186,0 +192,0 @@ on(event: 'error', listener: (err: Error) => void): this |
@@ -21,2 +21,11 @@ 'use strict'; | ||
// from: https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/node/zip.ts#L51 | ||
function modeFromEntry(entry) { | ||
const attr = entry.externalFileAttributes >> 16 || 33188; | ||
return [ 448 /* S_IRWXU */, 56 /* S_IRWXG */, 7 /* S_IRWXO */ ] | ||
.map(mask => attr & mask) | ||
.reduce((a, b) => a + b, attr & 61440 /* S_IFMT */); | ||
} | ||
class ZipUncompressStream extends UncompressBaseStream { | ||
@@ -81,2 +90,3 @@ constructor(opts) { | ||
.on('entry', entry => { | ||
const mode = modeFromEntry(entry); | ||
// fileName is buffer by default because decodeStrings = false | ||
@@ -97,3 +107,3 @@ if (Buffer.isBuffer(entry.fileName)) { | ||
const header = { name, type, yauzl: entry }; | ||
const header = { name, type, yauzl: entry, mode }; | ||
@@ -100,0 +110,0 @@ if (type === 'file') { |
{ | ||
"name": "compressing", | ||
"version": "1.5.1", | ||
"version": "1.6.0", | ||
"description": "Everything you need for compressing and uncompressing", | ||
"main": "index.js", | ||
"scripts": { | ||
"contributor": "git-contributor", | ||
"ts-test": "tsc -p ./test/fixtures/types/tsconfig.json", | ||
@@ -58,2 +59,3 @@ "test": "egg-bin test && npm run ts-test", | ||
"eslint-config-egg": "^3.2.0", | ||
"git-contributor": "^1.1.0", | ||
"mm": "^2.0.0", | ||
@@ -60,0 +62,0 @@ "mz-modules": "^2.1.0", |
# compressing | ||
[![NPM version][npm-image]][npm-url] | ||
[![build status][travis-image]][travis-url] | ||
[![Test coverage][codecov-image]][codecov-url] | ||
[![David deps][david-image]][david-url] | ||
[![Known Vulnerabilities][snyk-image]][snyk-url] | ||
[![npm download][download-image]][download-url] | ||
@@ -12,10 +9,4 @@ | ||
[npm-url]: https://npmjs.org/package/compressing | ||
[travis-image]: https://img.shields.io/travis/node-modules/compressing.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/node-modules/compressing | ||
[codecov-image]: https://codecov.io/gh/node-modules/compressing/branch/master/graph/badge.svg | ||
[codecov-url]: https://codecov.io/gh/node-modules/compressing | ||
[david-image]: https://img.shields.io/david/node-modules/compressing.svg?style=flat-square | ||
[david-url]: https://david-dm.org/node-modules/compressing | ||
[snyk-image]: https://snyk.io/test/npm/compressing/badge.svg?style=flat-square | ||
[snyk-url]: https://snyk.io/test/npm/compressing | ||
[download-image]: https://img.shields.io/npm/dm/compressing.svg?style=flat-square | ||
@@ -92,3 +83,2 @@ [download-url]: https://npmjs.org/package/compressing | ||
### Compress a dir | ||
@@ -172,5 +162,4 @@ | ||
**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.** | ||
__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.__ | ||
And working with urllib is super easy. Let's download a tgz file and uncompress to a directory: | ||
@@ -286,3 +275,3 @@ | ||
- source {String|Buffer|Stream} - source to be uncompressed | ||
- 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.** | ||
- 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.__ | ||
- opts {Object} - usually you don't need it | ||
@@ -381,2 +370,13 @@ - opts.zipFileNameEncoding {String} - Only work on zip format, default is 'utf8'. | ||
https://github.com/thejoshwolfe/yauzl#no-streaming-unzip-api | ||
<https://github.com/thejoshwolfe/yauzl#no-streaming-unzip-api> | ||
<!-- GITCONTRIBUTOR_START --> | ||
## Contributors | ||
|[<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/>| | ||
| :---: | :---: | :---: | :---: | :---: | :---: | | ||
[<img src="https://avatars.githubusercontent.com/u/9857273?v=4" width="100px;"/><br/><sub><b>ShadyZOZ</b></sub>](https://github.com/ShadyZOZ)<br/> | ||
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`. | ||
<!-- GITCONTRIBUTOR_END --> |
53142
948
14