Coder Social home page Coder Social logo

ogewan / node-unar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thetechstech/node-unar

0.0 0.0 0.0 192 KB

(Electron Support) ESM front-end to unar and lsar. The universal un-archiver/unpacker for .zip, zipx, rar, 7z, tar, gzip, bzip2, lzma, cab, msi, cpio, xar, exe, etc...

License: MIT License

JavaScript 100.00%

node-unar's Introduction

node-unar

NPM

Dependencies Status Node.js CI codecov MaintainabilityRelease

ESM front-end to unar and lsar a command line tool. The universal un-archiver/unpacker to a lot of formats: .zip, zipx, rar, 7z, tar, gzip, bzip2, lzma, cab, msi, cpio, xar, exe, etc....

The necessary cli tool lsar and unar, will be downloaded to package directory at install time, for Windows amd macOS. If your host is Linux, node-sys will be used to install unar onto your system.

Usage

//ESM Node JS v12+
import { list, unpack } from 'node-unar';

// list only:
list(archiveFile, options)
  .then((fileListArray) => {
  })
  .catch((anyError) => {
  });;

// unpack:
unpack(archiveFile, options | outputDirectory)
  .progress((eachFle) => {
  })
  .then((results) => {
    let type = results.type;
    let fileList = results.files;
    let outputDirectory = results.directory;
  })
  .catch((anyError) => {
  });

// unpack: only requested files/directories
unpack(archiveFile, outputDirectory, file | [files], options)
  .progress((eachFle) => {
  })
  .then((results) => {
    let type = results.type;
    let fileList = results.files;
    let outputDirectory = results.directory;
  })
  .catch((anyError) => {
  });

Examples

Example: unpack file

//ESM Node JS v12+
import  { unpack } from 'node-unar';

unpack('test/abc.rar', 'out')
  .progress((files) => {
    console.log('files', files);
  })
  .then((results) => {
    console.log('Archive type: ', results.type);
    console.log('Archive files', results.files);
    console.log('Archive output directory', results.directory);
  })
  .catch((err) => {
    console.error(err);
  });
});

Example: list content

//ESM Node JS v12+
import { list } from 'node-unar';

list('test/abc.rar')
  .then((files) => {
    console.log('files', files);
  })
  .catch((err) => {
    console.error(err);
  });

Options

Key Possible values Comment
quiet true/false (default) true will reduce logging for unpacking
targetDir <String> The directory to write the contents of the archive to. Defaults to the current directory.
files <String> Only unpack this list of files or directories.
forceOverwrite true/false (default) if null, tmp dir will created automatically
forceDirectory true/false/undefined Always create a containing directory for the contents of the unpacked archive. By default, a directory is created if there is more than one top-level file or folder.
noDirectory true/false/undefined Never create a containing directory for the contents of the unpacked archive.
noRecursion true/false/undefined Do not attempt to extract archives contained in other archives. For instance, when unpacking a .tar.gz file, only unpack the .gz file and not its contents.
copyTime true/false/undefined Copy the file modification time from the archive file to the containing directory, if one is created.
password <String> The password to use for decrypting protected archives.
passwordEncoding <String> The encoding to use for the password for the archive, when it is not known. If not specified, then either the encoding given by the -encoding option or the auto-detected encoding is used.
encoding <String> The encoding to use for filenames in the archive, when it is not known. If not specified, the program attempts to auto-detect the encoding used. Use "help" or "list" as the argument to give

node-unar's People

Contributors

thetechstech avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.