-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
801 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
18 | ||
22 |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,129 @@ | ||
|
||
## npm 包的对比 | ||
|
||
| | [`yauzl`][ygit] | [`extract-zip`][egit] | [`adm-zip`][agit] | [`unzipper`][ugit] | [`archiver`][argit] | | ||
|-----------------------|:--------------------:|:---------------------:|:------------------------:|:--------------------:|:----------------------:| | ||
| Issues open | [![][yio]][yio_a] | [![][eio]][eio_a] | [![][aio]][aio_a] | [![][uio]][uio_a] | [![][ario]][ario_a] | | ||
| Issues closed | [![][yic]][yic_a] | [![][eic]][eic_a] | [![][eic]][aic_a] | [![][uic]][uic_a] | [![][aric]][aric_a] | | ||
| Downloads | [![][yd]][yd_a] | [![][ed]][ed_a] | [![][ad]][ad_a] | [![][ud]][ud_a] | [![][ard]][ard_a] | | ||
| Bugs | [![][ybug]][ybug_a] | [![][ebug]][ebug_a] | [![][abug]][abug_a] | [![][ubug]][ubug_a] | [![][arbug]][arbug_a] | | ||
| Dependents | [![][ydp]][ydp_a] | [![][edp]][edp_a] | [![][adp]][adp_a] | [![][udp]][udp_a] | [![][ardp]][ardp_a] | | ||
| Install size | [![][ysize]][ysize_a]| [![][esize]][esize_a] | [![][asize]][asize_a] | [![][usize]][usize_a]| [![][arsize]][arsize_a]| | ||
| GitHub stars | [![][ystar]][ygit] | [![][estar]][egit] | [![][astar]][agit] | [![][ustar]][ugit] | [![][arstar]][argit] | | ||
| TypeScript support | [![][yts]][ygit] | [![][ets]][egit] | [![][ats]][agit] | [![][uts]][ugit] | [![][arts]][argit] | | ||
| Last commit | [![][ycm]][ycm_a] | [![][ecm]][ecm_a] | [![][acm]][acm_a] | [![][ucm]][ucm_a] | [![][arcm]][arcm_a] | | ||
| symlink support | :heavy_check_mark: | :heavy_check_mark: | :x: | ? | ? | | ||
|
||
|
||
<!-- GITHUB --> | ||
[ygit]: https://github.com/thejoshwolfe/yauzl | ||
[egit]: https://github.com/max-mapper/extract-zip | ||
[agit]: https://github.com/cthackers/adm-zip | ||
[ugit]: https://github.com/ZJONSSON/node-unzipper | ||
[argit]: https://github.com/archiverjs/node-archiver | ||
|
||
<!-- ISSUES OPEN --> | ||
[yio]: https://img.shields.io/github/issues-raw/thejoshwolfe/yauzl?color=gray&label | ||
[eio]: https://img.shields.io/github/issues-raw/max-mapper/extract-zip?color=gray&label | ||
[aio]: https://img.shields.io/github/issues-raw/cthackers/adm-zip?color=gray&label | ||
[uio]: https://img.shields.io/github/issues-raw/ZJONSSON/node-unzipper?color=gray&label | ||
[ario]: https://img.shields.io/github/issues-raw/archiverjs/node-archiver?color=gray&label | ||
|
||
[yio_a]: https://github.com/thejoshwolfe/yauzl/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc | ||
[eio_a]: https://github.com/max-mapper/extract-zip/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc | ||
[aio_a]: https://github.com/cthackers/adm-zip/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc | ||
[uio_a]: https://github.com/ZJONSSON/node-unzipper/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc | ||
[ario_a]: https://github.com/archiverjs/node-archiver/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc | ||
|
||
<!-- ISSUES CLOSED --> | ||
[yic]: https://img.shields.io/github/issues-closed-raw/thejoshwolfe/yauzl?color=blue&label | ||
[eic]: https://img.shields.io/github/issues-closed-raw/max-mapper/extract-zip?color=blue&label | ||
[aic]: https://img.shields.io/github/issues-closed-raw/cthackers/adm-zip?color=blue&label | ||
[uic]: https://img.shields.io/github/issues-closed-raw/ZJONSSON/node-unzipper?color=blue&label | ||
[aric]: https://img.shields.io/github/issues-closed-raw/archiverjs/node-archiver?color=blue&label | ||
|
||
[yic_a]: https://github.com/thejoshwolfe/yauzl/issues?q=is%3Aissue+is%3Aclosed+sort%3Aupdated-desc | ||
[eic_a]: https://github.com/max-mapper/extract-zip/issues?q=is%3Aissue+is%3Aclosed+sort%3Aupdated-desc | ||
[aic_a]: https://github.com/cthackers/adm-zip/issues?q=is%3Aissue+is%3Aclosed+sort%3Aupdated-desc | ||
[uic_a]: https://github.com/ZJONSSON/node-unzipper/issues?q=is%3Aissue+is%3Aclosed+sort%3Aupdated-desc | ||
[aric_a]: https://github.com/archiverjs/node-archiver/issues?q=is%3Aissue+is%3Aclosed+sort%3Aupdated-desc | ||
|
||
<!-- DOWNLOADS --> | ||
[yd]: https://img.shields.io/npm/dm/yauzl?color=darkgreen&label | ||
[ed]: https://img.shields.io/npm/dm/extract-zip?color=darkgreen&label | ||
[ad]: https://img.shields.io/npm/dm/adm-zip?color=darkgreen&label | ||
[ud]: https://img.shields.io/npm/dm/unzipper?color=darkgreen&label | ||
[ard]: https://img.shields.io/npm/dm/archiver?color=darkgreen&label | ||
|
||
[yd_a]: https://www.npmjs.com/package/yauzl | ||
[ed_a]: https://www.npmjs.com/package/extract-zip | ||
[ad_a]: https://www.npmjs.com/package/adm-zip | ||
[ud_a]: https://www.npmjs.com/package/unzipper | ||
[ard_a]: https://www.npmjs.com/package/archiver | ||
|
||
<!-- BUGS --> | ||
[ybug]: https://img.shields.io/github/issues-raw/thejoshwolfe/yauzl/bug?color=darkred&label | ||
[ebug]: https://img.shields.io/github/issues-raw/max-mapper/extract-zip/bug?color=darkred&label | ||
[abug]: https://img.shields.io/github/issues-raw/cthackers/adm-zip/bug?color=darkred&label | ||
[ubug]: https://img.shields.io/github/issues-raw/ZJONSSON/node-unzipper/bug-fix?color=darkred&label | ||
[arbug]: https://img.shields.io/github/issues-raw/archiverjs/node-archiver/Bug?color=darkred&label | ||
|
||
[ybug_a]: https://github.com/thejoshwolfe/yauzl/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Abug | ||
[ebug_a]: https://github.com/max-mapper/extract-zip/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Abug | ||
[abug_a]: https://github.com/cthackers/adm-zip/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Abug | ||
[ubug_a]: https://github.com/ZJONSSON/node-unzipper/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22bug-fix%22 | ||
[arbug_a]: https://github.com/archiverjs/node-archiver/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3ABug | ||
|
||
<!-- DEPENDENTS --> | ||
[ydp]: https://badgen.net/npm/dependents/yauzl?color=orange&label | ||
[edp]: https://badgen.net/npm/dependents/extract-zip?color=orange&label | ||
[adp]: https://badgen.net/npm/dependents/adm-zip?color=orange&label | ||
[udp]: https://badgen.net/npm/dependents/unzipper?color=orange&label | ||
[ardp]: https://badgen.net/npm/dependents/archiver?color=orange&label | ||
|
||
[ydp_a]: https://www.npmjs.com/package/yauzl?activeTab=dependents | ||
[edp_a]: https://www.npmjs.com/package/extract-zip?activeTab=dependents | ||
[adp_a]: https://www.npmjs.com/package/adm-zip?activeTab=dependents | ||
[udp_a]: https://www.npmjs.com/package/unzipper?activeTab=dependents | ||
[ardp_a]: https://www.npmjs.com/package/archiver?activeTab=dependents | ||
|
||
<!-- INSTALL SIZE --> | ||
[ysize]: https://packagephobia.com/badge?p=yauzl | ||
[esize]: https://packagephobia.com/badge?p=extract-zip | ||
[asize]: https://packagephobia.com/badge?p=adm-zip | ||
[usize]: https://packagephobia.com/badge?p=unzipper | ||
[arsize]: https://packagephobia.com/badge?p=archiver | ||
|
||
[ysize_a]: https://packagephobia.com/result?p=yauzl | ||
[esize_a]: https://packagephobia.com/result?p=extract-zip | ||
[asize_a]: https://packagephobia.com/result?p=adm-zip | ||
[usize_a]: https://packagephobia.com/result?p=unzipper | ||
[arsize_a]: https://packagephobia.com/result?p=archiver | ||
|
||
<!-- GITHUB STARS --> | ||
[ystar]: https://img.shields.io/github/stars/thejoshwolfe/yauzl?color=white&label | ||
[estar]: https://img.shields.io/github/stars/max-mapper/extract-zip?color=white&label | ||
[astar]: https://img.shields.io/github/stars/cthackers/adm-zip?color=white&label | ||
[ustar]: https://img.shields.io/github/stars/ZJONSSON/node-unzipper?color=white&label | ||
[arstar]: https://img.shields.io/github/stars/archiverjs/node-archiver?color=white&label | ||
|
||
|
||
<!-- TYPESCRIPT SUPPORT --> | ||
[yts]: https://badgen.net/npm/types/yauzl?label | ||
[ets]: https://badgen.net/npm/types/extract-zip?label | ||
[ats]: https://badgen.net/npm/types/adm-zip?label | ||
[uts]: https://badgen.net/npm/types/unzipper?label | ||
[arts]: https://badgen.net/npm/types/archiver?label | ||
|
||
<!-- LAST COMMIT --> | ||
[ycm]: https://img.shields.io/github/last-commit/thejoshwolfe/yauzl?color=gray&label | ||
[ecm]: https://img.shields.io/github/last-commit/max-mapper/extract-zip?color=gray&label | ||
[acm]: https://img.shields.io/github/last-commit/cthackers/adm-zip?color=gray&label | ||
[ucm]: https://img.shields.io/github/last-commit/ZJONSSON/node-unzipper?color=gray&label | ||
[arcm]: https://img.shields.io/github/last-commit/archiverjs/node-archiver?color=gray&label | ||
|
||
[ycm_a]: https://github.com/thejoshwolfe/yauzl/commits | ||
[ecm_a]: https://github.com/max-mapper/extract-zip/commits | ||
[acm_a]: https://github.com/cthackers/adm-zip/commits | ||
[ucm_a]: https://github.com/ZJONSSON/node-unzipper/commits | ||
[arcm_a]: https://github.com/archiverjs/node-archiver/commits |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { join } from 'node:path'; | ||
import { homedir } from 'os'; | ||
import { rimraf } from 'rimraf'; | ||
import { unzipDarwin, unzipWin32, unzipNpm } from './unzip.js'; | ||
|
||
const root = process.cwd(); | ||
|
||
const downloads = join(homedir(), 'Downloads'); | ||
const src = join(downloads, 'unzip-test-file.zip'); // 请在下载目录放置一个用于测试的 zip 文件 | ||
const dist = join(root, 'node_modules/0unzip/'); // 解压到 node_modules 不会影响 git | ||
|
||
async function testDarwin() { | ||
if (process.platform !== 'darwin') { | ||
return; | ||
} | ||
await rimraf(dist); | ||
console.time('unzipDarwin'); | ||
await unzipDarwin(src, dist); | ||
console.timeEnd('unzipDarwin'); | ||
} | ||
|
||
async function testWin32() { | ||
if (process.platform !== 'win32') { | ||
return; | ||
} | ||
await rimraf(dist); | ||
console.time('unzipWin32'); | ||
await unzipWin32(src, dist); | ||
console.timeEnd('unzipWin32'); | ||
} | ||
|
||
async function testNpm() { | ||
await rimraf(dist); | ||
console.time('unzipNpm'); | ||
await unzipNpm(src, dist); | ||
console.timeEnd('unzipNpm'); | ||
} | ||
|
||
await testDarwin(); | ||
await testWin32(); | ||
await testNpm(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "unzip", | ||
"type": "module", | ||
"main": "index.js", | ||
"dependencies": { | ||
"extract-zip": "^2.0.1" | ||
}, | ||
"devDependencies": { | ||
"rimraf": "^6.0.1" | ||
} | ||
} |
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use strict'; | ||
import { spawn } from 'node:child_process'; | ||
import extract from 'extract-zip'; | ||
import { join } from 'node:path'; | ||
|
||
const root = process.cwd(); | ||
|
||
/** | ||
* @param src | ||
* @param dist | ||
* @returns | ||
*/ | ||
export function unzipDarwin(src, dist) { | ||
return new Promise((resolve, reject) => { | ||
const child = spawn('unzip', ['-o', src, '-d', dist]); | ||
|
||
child.stdout.on('data', () => {}); // 必须消费标准输出,否则可能导致进程阻塞或挂起 | ||
child.stderr.on('data', console.error); | ||
|
||
child.on('close', (code) => { | ||
if (code === 0) { | ||
resolve(); | ||
} else { | ||
reject(code); | ||
} | ||
}); | ||
|
||
child.on('error', (err) => { | ||
reject(err); | ||
}); | ||
}); | ||
} | ||
|
||
export function unzipWin32(src, dist) { | ||
return new Promise((resolve, reject) => { | ||
//const child = spawn(join(root, 'unzip.exe'),['-n', src, '-d', dist]); | ||
|
||
const child = spawn(join(root, '7za.exe'), ['x', '-y', '-aoa', src, `-o${dist}`]); | ||
|
||
child.stdout.on('data', () => {}); | ||
child.stderr.on('data', console.error); | ||
|
||
child.on('close', (code) => { | ||
if (code === 0) { | ||
resolve(); | ||
} else { | ||
reject(code); | ||
} | ||
}); | ||
|
||
child.on('error', (err) => { | ||
reject(err); | ||
}); | ||
}); | ||
} | ||
|
||
export function unzipNpm(src, dist) { | ||
return extract(src, { dir: dist }); | ||
} |