compressing 1.10.2 → 1.10.3
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 +5 -8
- package/lib/utils.js +20 -12
- package/package.json +1 -3
package/README.md
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
[![NPM version][npm-image]][npm-url]
|
|
4
4
|
[![Test coverage][codecov-image]][codecov-url]
|
|
5
5
|
[![npm download][download-image]][download-url]
|
|
6
|
+
[](https://nodejs.org/en/download/)
|
|
7
|
+
[](https://makeapullrequest.com)
|
|
8
|
+

|
|
6
9
|
|
|
7
10
|
[npm-image]: https://img.shields.io/npm/v/compressing.svg?style=flat-square
|
|
8
11
|
[npm-url]: https://npmjs.org/package/compressing
|
|
@@ -364,15 +367,9 @@ Due to the design of the .zip file format, it's impossible to interpret a .zip f
|
|
|
364
367
|
Although the API is streaming style(try to keep it handy), it still loads all data into memory.
|
|
365
368
|
|
|
366
369
|
<https://github.com/thejoshwolfe/yauzl#no-streaming-unzip-api>
|
|
367
|
-
<!-- GITCONTRIBUTOR_START -->
|
|
368
370
|
|
|
369
371
|
## Contributors
|
|
370
372
|
|
|
371
|
-
|
|
372
|
-
| :---: | :---: | :---: | :---: | :---: | :---: |
|
|
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/>
|
|
373
|
+
[](https://github.com/node-modules/compressing/graphs/contributors)
|
|
375
374
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
<!-- GITCONTRIBUTOR_END -->
|
|
375
|
+
Made with [contributors-img](https://contrib.rocks).
|
package/lib/utils.js
CHANGED
|
@@ -109,31 +109,37 @@ exports.makeUncompressFn = StreamClass => {
|
|
|
109
109
|
.on('error', reject)
|
|
110
110
|
.on('entry', (header, stream, next) => {
|
|
111
111
|
stream.on('end', next);
|
|
112
|
+
const destFilePath = path.join(destDir, header.name);
|
|
112
113
|
|
|
113
114
|
if (header.type === 'file') {
|
|
114
|
-
const
|
|
115
|
-
mkdirp(
|
|
115
|
+
const dir = path.dirname(destFilePath);
|
|
116
|
+
mkdirp(dir, err => {
|
|
116
117
|
if (err) return reject(err);
|
|
117
118
|
|
|
118
119
|
entryCount++;
|
|
119
|
-
pump(stream, fs.createWriteStream(
|
|
120
|
+
pump(stream, fs.createWriteStream(destFilePath, { mode: opts.mode || header.mode }), err => {
|
|
120
121
|
if (err) return reject(err);
|
|
121
122
|
successCount++;
|
|
122
123
|
done();
|
|
123
124
|
});
|
|
124
125
|
});
|
|
125
126
|
} else if (header.type === 'symlink') {
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
const target = path.resolve(path.dirname(src), header.linkname);
|
|
127
|
+
const dir = path.dirname(destFilePath);
|
|
128
|
+
const target = path.resolve(dir, header.linkname);
|
|
129
129
|
entryCount++;
|
|
130
|
-
|
|
130
|
+
|
|
131
|
+
mkdirp(dir, err => {
|
|
131
132
|
if (err) return reject(err);
|
|
132
|
-
|
|
133
|
-
|
|
133
|
+
|
|
134
|
+
const relativeTarget = path.relative(dir, target);
|
|
135
|
+
fs.symlink(relativeTarget, destFilePath, err => {
|
|
136
|
+
if (err) return reject(err);
|
|
137
|
+
successCount++;
|
|
138
|
+
stream.resume();
|
|
139
|
+
});
|
|
134
140
|
});
|
|
135
141
|
} else { // directory
|
|
136
|
-
mkdirp(
|
|
142
|
+
mkdirp(destFilePath, err => {
|
|
137
143
|
if (err) return reject(err);
|
|
138
144
|
stream.resume();
|
|
139
145
|
});
|
|
@@ -175,7 +181,7 @@ function normalizePath(fileName) {
|
|
|
175
181
|
return fileName;
|
|
176
182
|
}
|
|
177
183
|
|
|
178
|
-
|
|
184
|
+
function stripFileName(strip, fileName, type) {
|
|
179
185
|
// before
|
|
180
186
|
// node/package.json
|
|
181
187
|
// node/lib/index.js
|
|
@@ -218,4 +224,6 @@ exports.stripFileName = (strip, fileName, type) => {
|
|
|
218
224
|
|
|
219
225
|
strip = Math.min(strip, s.length - 1);
|
|
220
226
|
return s.slice(strip).join('/') || '/';
|
|
221
|
-
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
exports.stripFileName = stripFileName;
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "compressing",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.3",
|
|
4
4
|
"description": "Everything you need for compressing and uncompressing",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"contributor": "git-contributor",
|
|
8
7
|
"test:ts": "tsc -p ./test/fixtures/types/tsconfig.json",
|
|
9
8
|
"test:js": "egg-bin test --ts false",
|
|
10
9
|
"test": "npm run test:js && npm run test:ts",
|
|
@@ -57,7 +56,6 @@
|
|
|
57
56
|
"egg-bin": "6",
|
|
58
57
|
"eslint": "8",
|
|
59
58
|
"eslint-config-egg": "12",
|
|
60
|
-
"git-contributor": "2",
|
|
61
59
|
"mm": "^2.0.0",
|
|
62
60
|
"mz-modules": "^2.1.0",
|
|
63
61
|
"typescript": "5",
|