forked from EvanOxfeld/node-unzip
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved from fstream to fs-extra package, as fstream is no longer suppo…
…rted and its dependencies contains vulnerability Removed and replaced vulnerable packages
- Loading branch information
Showing
6 changed files
with
96 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,10 @@ | |
{ | ||
"name": "Joe Ferner", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "Ayush Aher", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"repository": { | ||
|
@@ -23,22 +27,22 @@ | |
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"axios": "^1.7.2", | ||
"big-integer": "^1.6.17", | ||
"bluebird": "~3.4.1", | ||
"duplexer2": "~0.1.4", | ||
"fstream": "^1.0.12", | ||
"fs-extra": "^11.2.0", | ||
"graceful-fs": "^4.2.2" | ||
}, | ||
"devDependencies": { | ||
"@eslint/js": "^9.2.0", | ||
"aws-sdk": "^2.77.0", | ||
"aws-sdk": "^2.1636.0", | ||
"dirdiff": ">= 0.0.1 < 1", | ||
"eslint": "^9.2.0", | ||
"globals": "^15.2.0", | ||
"iconv-lite": "^0.4.24", | ||
"request": "^2.88.0", | ||
"stream-buffers": ">= 0.2.5 < 1", | ||
"tap": "^12.7.0", | ||
"tap": "^19.2.2", | ||
"temp": ">= 0.4.0 < 1" | ||
}, | ||
"directories": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,41 @@ | ||
const test = require("tap").test; | ||
const fs = require("fs"); | ||
const unzip = require("../"); | ||
const os = require("os"); | ||
const request = require("request"); | ||
const axios = require("axios"); | ||
const path = require("path"); | ||
|
||
test("extract zip from url", function (t) { | ||
const extractPath = os.tmpdir() + "/node-unzip-extract-fromURL"; // Not using path resolve, cause it should be resolved in extract() function | ||
unzip.Open.url( | ||
request, | ||
"https://github.com/h5bp/html5-boilerplate/releases/download/v7.3.0/html5-boilerplate_v7.3.0.zip" | ||
) | ||
.then(function(d) { return d.extract({ path: extractPath }); }) | ||
.then(function() { | ||
const dirFiles = fs.readdirSync(extractPath); | ||
const isPassing = | ||
dirFiles.length > 10 && | ||
dirFiles.indexOf("css") > -1 && | ||
dirFiles.indexOf("index.html") > -1 && | ||
dirFiles.indexOf("favicon.ico") > -1; | ||
test("extract zip from url", async function (t) { | ||
const extractPath = path.join("../node-unzip-extract-fromURL"); // Ensure path is constructed correctly | ||
const url = | ||
"https://github.com/h5bp/html5-boilerplate/releases/download/v7.3.0/html5-boilerplate_v7.3.0.zip"; | ||
|
||
t.equal(isPassing, true); | ||
t.end(); | ||
try { | ||
// Fetch the zip file | ||
const response = await axios({ | ||
method: "get", | ||
url: url, | ||
responseType: "arraybuffer", // Download the file as a buffer | ||
}); | ||
|
||
// Buffer the response data | ||
const buffer = Buffer.from(response.data); | ||
|
||
// Extract the buffer | ||
const directory = await unzip.Open.buffer(buffer); | ||
await directory.extract({ path: extractPath }); | ||
|
||
// Check extracted files | ||
const dirFiles = fs.readdirSync(extractPath); | ||
const isPassing = | ||
dirFiles.length > 10 && | ||
dirFiles.indexOf("css") > -1 && | ||
dirFiles.indexOf("index.html") > -1 && | ||
dirFiles.indexOf("favicon.ico") > -1; | ||
|
||
t.equal(isPassing, true); | ||
} catch (error) { | ||
t.fail(error.message); | ||
} finally { | ||
t.end(); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters