@jeffy-g/unzip
Version:

55 lines (37 loc) • 1.38 kB
Markdown

>use fflate unzip feature
+ all zip file extract to `<output directory>`
If you need a detailed log, please specify the `-v` option.
```
$ ffunzip [-v] [-d <output directory>] <zip file> <zip file> <zip file> ...
```
+ NOTE: if `-d` omitted then output directory to `./output`
```js
// DEVNOTE: 2024/01/01 - "colors.ts" available
const unzipWithCallback = require("@jeffy-g/unzip");
/** @type {(path: TSimpleZipEntry) => void} */
const withCallback = e => {
// means you are scanning for zip entries
if (e.state === "info") {
console.log(`zip info [${e.size? "f": "d"}]: ${e.path}`.gray);
} else if (e.state === "File") {
const state = e.state;
const color = state === "pending" ? "cyan": "green";
console.log(`${state} - ${
e.path[color]}${state !== "write" ? `, size: ${e.size?.toLocaleString().blue}`: ""
}`);
}
// else if (e.state === "ignore" || e.type === "Folder") {
// // do nothing
// }
};
unzipWithCallback("[zipPath]", "[output directory]", withCallback);
```
>
- **jeffy-g** - [jeffy-g](https://github.com/jeffy-g)
>
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details