Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
enecciariatbl committed Jul 5, 2020
2 parents a6f7ac2 + 9d2eb0b commit 218feee
Show file tree
Hide file tree
Showing 12 changed files with 1,145 additions and 31 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Expand Up @@ -3,8 +3,9 @@ sudo: false
language: node_js

node_js:
- 8
- 6
- 'stable'
- 12
- 10

cache:
directories:
Expand Down
2 changes: 1 addition & 1 deletion MIT-LICENSE.txt → LICENSE
Expand Up @@ -18,4 +18,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 changes: 4 additions & 4 deletions README.md
@@ -1,13 +1,13 @@
# ADM-ZIP for NodeJS with added support for electron original-fs

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

# Installation

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

$ npm install adm-zip

## What is it good for?
The library allows you to:

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

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

[![build status](https://secure.travis-ci.org/cthackers/adm-zip.png)](http://travis-ci.org/cthackers/adm-zip)
[![Build Status](https://travis-ci.org/cthackers/adm-zip.svg?branch=master)](https://travis-ci.org/cthackers/adm-zip)
22 changes: 11 additions & 11 deletions adm-zip.js
Expand Up @@ -19,7 +19,7 @@ module.exports = function (/**String*/input) {
_filename = input;
_zip = new ZipFile(input, Utils.Constants.FILE);
} else {
throw Utils.Errors.INVALID_FILENAME;
throw new Error(Utils.Errors.INVALID_FILENAME);
}
} else if (input && Buffer.isBuffer(input)) { // load buffer
_zip = new ZipFile(input, Utils.Constants.BUFFER);
Expand Down Expand Up @@ -226,7 +226,7 @@ module.exports = function (/**String*/input) {
this.addFile(zipPath + p, fs.readFileSync(localPath), "", 0)
}
} else {
throw Utils.Errors.FILE_NOT_FOUND.replace("%s", localPath);
throw new Error(Utils.Errors.FILE_NOT_FOUND.replace("%s", localPath));
}
},

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

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

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

var item = getEntry(entry);
if (!item) {
throw Utils.Errors.NO_ENTRY;
throw new Error(Utils.Errors.NO_ENTRY);
}

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

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

var content = item.getData();
if (!content) throw Utils.Errors.CANT_EXTRACT_FILE;
if (!content) throw new Error(Utils.Errors.CANT_EXTRACT_FILE);

if (fs.existsSync(target) && !overwrite) {
throw Utils.Errors.CANT_OVERRIDE;
throw new Error(Utils.Errors.CANT_OVERRIDE);
}
Utils.writeFileTo(target, content, overwrite);

Expand Down Expand Up @@ -513,7 +513,7 @@ module.exports = function (/**String*/input) {
extractAllTo: function (/**String*/targetPath, /**Boolean*/overwrite) {
overwrite = overwrite || false;
if (!_zip) {
throw Utils.Errors.NO_ZIP;
throw new Error(Utils.Errors.NO_ZIP);
}
_zip.entries.forEach(function (entry) {
var entryName = sanitize(targetPath, entry.entryName.toString());
Expand All @@ -523,13 +523,13 @@ module.exports = function (/**String*/input) {
}
var content = entry.getData();
if (!content) {
throw Utils.Errors.CANT_EXTRACT_FILE;
throw new Error(Utils.Errors.CANT_EXTRACT_FILE);
}
Utils.writeFileTo(entryName, content, overwrite);
try {
fs.utimesSync(entryName, entry.header.time, entry.header.time)
} catch (err) {
throw Utils.Errors.CANT_EXTRACT_FILE;
throw new Error(Utils.Errors.CANT_EXTRACT_FILE);
}
})
},
Expand Down
4 changes: 2 additions & 2 deletions headers/entryHeader.js
Expand Up @@ -110,7 +110,7 @@ module.exports = function () {
var data = input.slice(_offset, _offset + Constants.LOCHDR);
// 30 bytes and should start with "PK\003\004"
if (data.readUInt32LE(0) !== Constants.LOCSIG) {
throw Utils.Errors.INVALID_LOC;
throw new Error(Utils.Errors.INVALID_LOC);
}
_dataHeader = {
// version needed to extract
Expand All @@ -137,7 +137,7 @@ module.exports = function () {
loadFromBinary : function(/*Buffer*/data) {
// data should be 46 bytes and start with "PK 01 02"
if (data.length !== Constants.CENHDR || data.readUInt32LE(0) !== Constants.CENSIG) {
throw Utils.Errors.INVALID_CEN;
throw new Error(Utils.Errors.INVALID_CEN);
}
// version made by
_verMade = data.readUInt16LE(Constants.CENVEM);
Expand Down
2 changes: 1 addition & 1 deletion headers/mainHeader.js
Expand Up @@ -35,7 +35,7 @@ module.exports = function () {
if ((data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) &&
(data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)) {

throw Utils.Errors.INVALID_END;
throw new Error(Utils.Errors.INVALID_END);
}

if (data.readUInt32LE(0) === Constants.ENDSIG) {
Expand Down

0 comments on commit 218feee

Please sign in to comment.