Giter VIP home page Giter VIP logo

ziptool's Introduction

Ziptool

A simple tool to zip and unzip from the command line or from your code.

Requirements

Installation

Ziptool can be installed globally: npm install ziptool -g

or locally into your npm project: npm install ziptool --save

Usage

  • CLI

    Globally installed

    Ziptool can be used directly from the command line to zip/unzip files:

    # Zip file-1.txt and file-2.png into a new zip archive 'zip-archive':
    ziptool --zip file-1.txt file-2.png -o zip-archive.zip
    
    # Extract the files from my-archive.zip into the directory 'my-directory':
    ziptool --unzip my-archive.zip -o zip-archive.zip

    For more information, run the command: ziptool --help

    Locally installed

    If ziptool is installed locally, you need to replace the 'ziptool' command by node node_modules/ziptool/bin/ziptool or by adding scripts into your package.json file:

      "scripts": [
        "ziptool": "ziptool"
      ]
  • Code

    Example

    Ziptool's api is also available to use in your Node.js javascript files, simply require it:

    const ziptool = require('ziptool');

    You can also require only the functions you need:

    const {zip} = require('ziptool');

    References

    • VERSION: constant

      /**
       * Current ziptool's version.
       * @const {string}
       */

      Example:

      console.log(ziptool.VERSION); // Will print the package's version you are using
    • zip (src, dest, callback): function

      /**
       * Create a zip archive from one or multiple files.
       * @param {string|Array<string>} src - The pathname(s) of the file(s) to compress.
       * @param {string} dest - The pathname of the zip archive to create.
       * @param {Function} callback - The function called after the zip archive has
       * been created or if an error occured.
       */

      Example:

      zip(['file1.jpg', 'file2.png', 'file4.mp3'], 'idk.zip', (err) => {
        // err is given to the callback as an argument.
        // It is either null (= no error) or an Error instance (= error)
        if (err) throw err;
      });
    • unzip (src, dest, callback): function

      /**
       * Extract a zip archive to a specified location.
       * @param {string} src - The zip archive filepath to be extracted.
       * @param {string} dest - The directory path to extract the zip archive to.
       * @param {Function} callback - The function called after the zip archive has
       * been extracted or if an error occured.
       */

      Example:

      unzip('idk.zip', 'a-directory', (err) => {
        // err is given to the callback as an argument.
        // It is either null (= no error) or an Error instance (= error)
        if (err) throw err;
      });

<3.

ziptool's People

Contributors

dgbrokaw avatar nayayayay avatar

Watchers

 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.