Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zip-a-folder

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zip-a-folder - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

7

lib/zip-a-folder.js

@@ -8,2 +8,7 @@ 'use strict';

static async zip(srcFolder, zipFilePath) {
const targetBasePath = path.dirname(zipFilePath);
if (targetBasePath === srcFolder) {
throw new Error('Source and target folder must be different.');
}
return new Promise((resolve, reject) => {

@@ -44,2 +49,2 @@ ZipAFolder.zipFolder(srcFolder, zipFilePath, err => {

module.exports = ZipAFolder;
module.exports = ZipAFolder;

8

package.json
{
"name": "zip-a-folder",
"version": "0.0.10",
"version": "0.0.11",
"description": "Forked the idea of @sole to zip a complete folder into a zip file but now using promises",

@@ -31,7 +31,7 @@ "main": "lib/zip-a-folder.js",

"devDependencies": {
"coveralls": "^3.0.6",
"eslint-plugin-jest": "^22.15.2",
"coveralls": "^3.0.9",
"eslint-plugin-jest": "^22.21.0",
"jest": "^24.9.0",
"lodash": "^4.17.15",
"prettier": "^1.18.2"
"prettier": "^1.19.1"
},

@@ -38,0 +38,0 @@ "dependencies": {

@@ -1,56 +0,63 @@

"use strict";
'use strict';
const fs = require("fs");
const path = require("path");
const zipafolder = require("../lib/zip-a-folder");
const fs = require('fs');
const path = require('path');
const zipafolder = require('../lib/zip-a-folder');
describe("Zip-A-Folder Test", function() {
let testasync = path.resolve(__dirname, "testasync.zip");
let testcallback = path.resolve(__dirname, "testcallback.zip");
let testnotexisting = path.resolve(__dirname, "/notexisting/testcallback.zip");
describe('Zip-A-Folder Test', function() {
let testasync = path.resolve(__dirname, 'testasync.zip');
let testasyncSameDirectory = path.resolve(__dirname, 'data/testasync.zip');
let testcallback = path.resolve(__dirname, 'testcallback.zip');
let testnotexisting = path.resolve(__dirname, '/notexisting/testcallback.zip');
beforeAll(() => {
if (fs.existsSync(testasync)) {
fs.unlinkSync(testasync);
}
if (fs.existsSync(testcallback)) {
fs.unlinkSync(testcallback);
}
});
beforeAll(() => {
if (fs.existsSync(testasync)) {
fs.unlinkSync(testasync);
}
if (fs.existsSync(testasyncSameDirectory)) {
fs.unlinkSync(testasyncSameDirectory);
}
if (fs.existsSync(testcallback)) {
fs.unlinkSync(testcallback);
}
});
it("ASYNC: Zip test folder", async function() {
expect.assertions(1);
await zipafolder.zip(path.resolve(__dirname, "data/"), testasync);
it('ASYNC: Zip test folder and zip target in same directory should throw an error', async () => {
expect.assertions(1);
await expect(zipafolder.zip(path.resolve(__dirname, 'data/'), testasyncSameDirectory)).rejects.toThrow(
/Source and target folder must be different./
);
});
expect(fs.existsSync(testasync)).toBe(true);
});
it('ASYNC: Zip test folder', async () => {
expect.assertions(1);
await zipafolder.zip(path.resolve(__dirname, 'data/'), testasync);
it("ASYNC: Zip test folder failing", async function() {
expect.assertions(1);
try {
await zipafolder.zip(path.resolve(__dirname, "notexisting/"), testasync);
} catch (e) {
expect(e.message).toMatch(/no such file or directory/);
}
});
expect(fs.existsSync(testasync)).toBe(true);
});
it("ASYNC: Zip test folder into a zipfile in a notexisting folder", async function() {
expect.assertions(1);
it('ASYNC: Zip test folder failing', async () => {
expect.assertions(1);
try {
await zipafolder.zip(path.resolve(__dirname, 'notexisting/'), testasync);
} catch (e) {
expect(e.message).toMatch(/no such file or directory/);
}
});
try {
await zipafolder.zip(path.resolve(__dirname, "data/"), testnotexisting);
} catch (e) {
expect(e.message).toMatch(/no such file or directory/);
}
});
it('ASYNC: Zip test folder into a zipfile in a notexisting folder', async () => {
expect.assertions(1);
it("CALLBACK: Zip test folder", function() {
zipafolder.zipFolder(
path.resolve(__dirname, "data/"),
testcallback,
() => {
expect(fs.existsSync(testcallback)).toBe(true);
}
);
});
try {
await zipafolder.zip(path.resolve(__dirname, 'data/'), testnotexisting);
} catch (e) {
expect(e.message).toMatch(/no such file or directory/);
}
});
it('CALLBACK: Zip test folder', () => {
zipafolder.zipFolder(path.resolve(__dirname, 'data/'), testcallback, () => {
expect(fs.existsSync(testcallback)).toBe(true);
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc