UNPKG

@jeffy-g/unzip

Version:

![GitHub](https://img.shields.io/github/license/jeffy-g/rm-cstyle-cmts?style=flat)

46 lines 1.47 kB
#!/usr/bin/env node /*! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Copyright (C) 2024 jeffy-g <hirotom1107@gmail.com> Released under the MIT license https://opensource.org/licenses/mit-license.php - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /// <reference path="./ffunzip.d.ts"/> const tinArgs = require("tin-args"); const unzipWithCallback = require("./index"); /** * @type {ReturnType<typeof tinArgs<TUnzipArgs>>} */ const params = tinArgs(); const verbose = params.v; /** @type {TUnzipCallback} */ const withCallback = (() => { if (verbose) { /** @type {typeof console.log} */ const log = console.log.bind(console, "[unzip]:".magenta); return e => { if (typeof e === "string") { log(`${e} unzip done`); return; } if (e.state === "info") { log(`zip info [${e.size? "f": "d"}]: ${e.path}`.hex("444444")); } else if (e.state === "ignore" || e.type === "Folder") { } else { const state = e.state; const color = state === "pending" ? "cyan": "green"; log(`${state} - ${e.path[color]}${ state !== "write" ? `, size: ${e.size?.toLocaleString().blue}`: "" }`); } }; } return e => {}; })(); const dest = params.d || "./output"; params.args?.forEach((zipPath) => { console.log(`ffunzip: processing - ${zipPath}`); unzipWithCallback(zipPath, dest, withCallback); });