Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ZipLocal.sync.zip = function(entity, buffer_name) {
var zipped_obj = JSZip.make();
if (typeof entity === "string") {
// the entity is a path pointing to a file or a directory
var normalized_path = path.normalize(entity);
var stats = fs.statSync(normalized_path);
if (stats.isDirectory()) {
// start zipping the directory
zip_dir_sync(normalized_path, zipped_obj);
return new ZipExport(zipped_obj);
}
else {
ZipLocal.sync.unzip = function (file) {
var zipped_obj = JSZip.make();
if (typeof file === "string") {
// file is a path that points to a zip file
var normalized_path = path.normalize(file);
var data = fs.readFileSync(normalized_path);
zipped_obj.load(data);
}
else if (file instanceof Buffer) {
// file is a Buffer that contains the data
zipped_obj.load(file);
ZipLocal.zip = function (entity, _callback, _shiftedCallback) {
var zipped_obj = JSZip.make();
if (typeof entity === "string") {
// the entity is a path pointing to a file or a directory
// the callback is not shifted
var callback = _callback || function () { };
var normalized_path = path.normalize(entity);
fs.stat(normalized_path, function (err, stats) {
if (err) {
callback(err);
return;
}