Skip to content

Commit 218feee

Browse files
committedJul 5, 2020
Merge remote-tracking branch 'upstream/master'
2 parents a6f7ac2 + 9d2eb0b commit 218feee

File tree

12 files changed

+1145
-31
lines changed

12 files changed

+1145
-31
lines changed
 

‎.travis.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ sudo: false
33
language: node_js
44

55
node_js:
6-
- 8
7-
- 6
6+
- 'stable'
7+
- 12
8+
- 10
89

910
cache:
1011
directories:

‎MIT-LICENSE.txt renamed to ‎LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1818
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1919
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2020
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

‎README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# ADM-ZIP for NodeJS with added support for electron original-fs
22

3-
ADM-ZIP is a pure JavaScript implementation for zip data compression for [NodeJS](http://nodejs.org/).
3+
ADM-ZIP is a pure JavaScript implementation for zip data compression for [NodeJS](https://nodejs.org/).
44

55
# Installation
66

7-
With [npm](http://npmjs.org) do:
7+
With [npm](https://www.npmjs.com/) do:
88

99
$ npm install adm-zip
10-
10+
1111
## What is it good for?
1212
The library allows you to:
1313

@@ -62,4 +62,4 @@ There are no other nodeJS libraries that ADM-ZIP is dependent of
6262

6363
For more detailed information please check out the [wiki](https://github.com/cthackers/adm-zip/wiki).
6464

65-
[![build status](https://secure.travis-ci.org/cthackers/adm-zip.png)](http://travis-ci.org/cthackers/adm-zip)
65+
[![Build Status](https://travis-ci.org/cthackers/adm-zip.svg?branch=master)](https://travis-ci.org/cthackers/adm-zip)

‎adm-zip.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = function (/**String*/input) {
1919
_filename = input;
2020
_zip = new ZipFile(input, Utils.Constants.FILE);
2121
} else {
22-
throw Utils.Errors.INVALID_FILENAME;
22+
throw new Error(Utils.Errors.INVALID_FILENAME);
2323
}
2424
} else if (input && Buffer.isBuffer(input)) { // load buffer
2525
_zip = new ZipFile(input, Utils.Constants.BUFFER);
@@ -226,7 +226,7 @@ module.exports = function (/**String*/input) {
226226
this.addFile(zipPath + p, fs.readFileSync(localPath), "", 0)
227227
}
228228
} else {
229-
throw Utils.Errors.FILE_NOT_FOUND.replace("%s", localPath);
229+
throw new Error(Utils.Errors.FILE_NOT_FOUND.replace("%s", localPath));
230230
}
231231
},
232232

@@ -272,7 +272,7 @@ module.exports = function (/**String*/input) {
272272

273273
if (items.length) {
274274
items.forEach(function (path) {
275-
var p = path.split("\\").join("/").replace(new RegExp(localPath.replace(/(\(|\))/g, '\\$1'), 'i'), ""); //windows fix
275+
var p = path.split("\\").join("/").replace(new RegExp(localPath.replace(/(\(|\)|\$)/g, '\\$1'), 'i'), ""); //windows fix
276276
if (filter(p)) {
277277
if (p.charAt(p.length - 1) !== "/") {
278278
self.addFile(zipPath + p, fs.readFileSync(path), "", 0)
@@ -283,7 +283,7 @@ module.exports = function (/**String*/input) {
283283
});
284284
}
285285
} else {
286-
throw Utils.Errors.FILE_NOT_FOUND.replace("%s", localPath);
286+
throw new Error(Utils.Errors.FILE_NOT_FOUND.replace("%s", localPath));
287287
}
288288
},
289289

@@ -444,7 +444,7 @@ module.exports = function (/**String*/input) {
444444

445445
var item = getEntry(entry);
446446
if (!item) {
447-
throw Utils.Errors.NO_ENTRY;
447+
throw new Error(Utils.Errors.NO_ENTRY);
448448
}
449449

450450
var entryName = item.entryName;
@@ -458,7 +458,7 @@ module.exports = function (/**String*/input) {
458458
if (child.isDirectory) return;
459459
var content = child.getData();
460460
if (!content) {
461-
throw Utils.Errors.CANT_EXTRACT_FILE;
461+
throw new Error(Utils.Errors.CANT_EXTRACT_FILE);
462462
}
463463
var childName = sanitize(targetPath, maintainEntryPath ? child.entryName : pth.basename(child.entryName));
464464

@@ -468,10 +468,10 @@ module.exports = function (/**String*/input) {
468468
}
469469

470470
var content = item.getData();
471-
if (!content) throw Utils.Errors.CANT_EXTRACT_FILE;
471+
if (!content) throw new Error(Utils.Errors.CANT_EXTRACT_FILE);
472472

473473
if (fs.existsSync(target) && !overwrite) {
474-
throw Utils.Errors.CANT_OVERRIDE;
474+
throw new Error(Utils.Errors.CANT_OVERRIDE);
475475
}
476476
Utils.writeFileTo(target, content, overwrite);
477477

@@ -513,7 +513,7 @@ module.exports = function (/**String*/input) {
513513
extractAllTo: function (/**String*/targetPath, /**Boolean*/overwrite) {
514514
overwrite = overwrite || false;
515515
if (!_zip) {
516-
throw Utils.Errors.NO_ZIP;
516+
throw new Error(Utils.Errors.NO_ZIP);
517517
}
518518
_zip.entries.forEach(function (entry) {
519519
var entryName = sanitize(targetPath, entry.entryName.toString());
@@ -523,13 +523,13 @@ module.exports = function (/**String*/input) {
523523
}
524524
var content = entry.getData();
525525
if (!content) {
526-
throw Utils.Errors.CANT_EXTRACT_FILE;
526+
throw new Error(Utils.Errors.CANT_EXTRACT_FILE);
527527
}
528528
Utils.writeFileTo(entryName, content, overwrite);
529529
try {
530530
fs.utimesSync(entryName, entry.header.time, entry.header.time)
531531
} catch (err) {
532-
throw Utils.Errors.CANT_EXTRACT_FILE;
532+
throw new Error(Utils.Errors.CANT_EXTRACT_FILE);
533533
}
534534
})
535535
},

‎headers/entryHeader.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ module.exports = function () {
110110
var data = input.slice(_offset, _offset + Constants.LOCHDR);
111111
// 30 bytes and should start with "PK\003\004"
112112
if (data.readUInt32LE(0) !== Constants.LOCSIG) {
113-
throw Utils.Errors.INVALID_LOC;
113+
throw new Error(Utils.Errors.INVALID_LOC);
114114
}
115115
_dataHeader = {
116116
// version needed to extract
@@ -137,7 +137,7 @@ module.exports = function () {
137137
loadFromBinary : function(/*Buffer*/data) {
138138
// data should be 46 bytes and start with "PK 01 02"
139139
if (data.length !== Constants.CENHDR || data.readUInt32LE(0) !== Constants.CENSIG) {
140-
throw Utils.Errors.INVALID_CEN;
140+
throw new Error(Utils.Errors.INVALID_CEN);
141141
}
142142
// version made by
143143
_verMade = data.readUInt16LE(Constants.CENVEM);

‎headers/mainHeader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = function () {
3535
if ((data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) &&
3636
(data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)) {
3737

38-
throw Utils.Errors.INVALID_END;
38+
throw new Error(Utils.Errors.INVALID_END);
3939
}
4040

4141
if (data.readUInt32LE(0) === Constants.ENDSIG) {

0 commit comments

Comments
 (0)