Update checked-in dependencies
This commit is contained in:
parent
2bb35eab2f
commit
200dd0cf5b
88 changed files with 1039 additions and 527 deletions
88
node_modules/adm-zip/adm-zip.js
generated
vendored
88
node_modules/adm-zip/adm-zip.js
generated
vendored
|
|
@ -429,7 +429,7 @@ module.exports = function (/**String*/ input, /** object */ options) {
|
|||
// prepare new entry
|
||||
if (!update) {
|
||||
entry = new ZipEntry();
|
||||
entry.entryName = entryName;
|
||||
entry.entryName = Utils.canonical(entryName);
|
||||
}
|
||||
entry.comment = comment || "";
|
||||
|
||||
|
|
@ -464,6 +464,8 @@ module.exports = function (/**String*/ input, /** object */ options) {
|
|||
|
||||
entry.setData(content);
|
||||
if (!update) _zip.setEntry(entry);
|
||||
|
||||
return entry;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -472,7 +474,7 @@ module.exports = function (/**String*/ input, /** object */ options) {
|
|||
* @return Array
|
||||
*/
|
||||
getEntries: function (/**String*/ password) {
|
||||
_zip.password=password;
|
||||
_zip.password = password;
|
||||
return _zip ? _zip.entries : [];
|
||||
},
|
||||
|
||||
|
|
@ -635,13 +637,20 @@ module.exports = function (/**String*/ input, /** object */ options) {
|
|||
* @param callback The callback will be executed when all entries are extracted successfully or any error is thrown.
|
||||
*/
|
||||
extractAllToAsync: function (/**String*/ targetPath, /**Boolean*/ overwrite, /**Boolean*/ keepOriginalPermission, /**Function*/ callback) {
|
||||
if (typeof overwrite === "function" && !callback) callback = overwrite;
|
||||
overwrite = get_Bool(overwrite, false);
|
||||
if (typeof keepOriginalPermission === "function" && !callback) callback = keepOriginalPermission;
|
||||
keepOriginalPermission = get_Bool(keepOriginalPermission, false);
|
||||
if (!callback) {
|
||||
callback = function (err) {
|
||||
throw new Error(err);
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
this.extractAllToAsync(targetPath, overwrite, keepOriginalPermission, function (err) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(this);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
if (!_zip) {
|
||||
callback(new Error(Utils.Errors.NO_ZIP));
|
||||
|
|
@ -655,12 +664,12 @@ module.exports = function (/**String*/ input, /** object */ options) {
|
|||
|
||||
// separate directories from files
|
||||
const dirEntries = [];
|
||||
const fileEntries = new Set();
|
||||
const fileEntries = [];
|
||||
_zip.entries.forEach((e) => {
|
||||
if (e.isDirectory) {
|
||||
dirEntries.push(e);
|
||||
} else {
|
||||
fileEntries.add(e);
|
||||
fileEntries.push(e);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -680,47 +689,38 @@ module.exports = function (/**String*/ input, /** object */ options) {
|
|||
}
|
||||
}
|
||||
|
||||
// callback wrapper, for some house keeping
|
||||
const done = () => {
|
||||
if (fileEntries.size === 0) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
// Extract file entries asynchronously
|
||||
for (const entry of fileEntries.values()) {
|
||||
const entryName = pth.normalize(canonical(entry.entryName.toString()));
|
||||
const filePath = sanitize(targetPath, entryName);
|
||||
entry.getDataAsync(function (content, err_1) {
|
||||
if (err_1) {
|
||||
callback(new Error(err_1));
|
||||
return;
|
||||
}
|
||||
if (!content) {
|
||||
callback(new Error(Utils.Errors.CANT_EXTRACT_FILE));
|
||||
fileEntries.reverse().reduce(function (next, entry) {
|
||||
return function (err) {
|
||||
if (err) {
|
||||
next(err);
|
||||
} else {
|
||||
// The reverse operation for attr depend on method addFile()
|
||||
const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
|
||||
filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function (succ) {
|
||||
if (!succ) {
|
||||
callback(getError("Unable to write file", filePath));
|
||||
return;
|
||||
const entryName = pth.normalize(canonical(entry.entryName.toString()));
|
||||
const filePath = sanitize(targetPath, entryName);
|
||||
entry.getDataAsync(function (content, err_1) {
|
||||
if (err_1) {
|
||||
next(new Error(err_1));
|
||||
} else if (!content) {
|
||||
next(new Error(Utils.Errors.CANT_EXTRACT_FILE));
|
||||
} else {
|
||||
// The reverse operation for attr depend on method addFile()
|
||||
const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
|
||||
filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function (succ) {
|
||||
if (!succ) {
|
||||
next(getError("Unable to write file", filePath));
|
||||
}
|
||||
filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function (err_2) {
|
||||
if (err_2) {
|
||||
next(getError("Unable to set times", filePath));
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function (err_2) {
|
||||
if (err_2) {
|
||||
callback(getError("Unable to set times", filePath));
|
||||
return;
|
||||
}
|
||||
// call the callback if it was last entry
|
||||
done();
|
||||
fileEntries.delete(entry);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
// call the callback if fileEntries was empty
|
||||
done();
|
||||
};
|
||||
}, callback)();
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue