Neanderthals Paint Mammals

    ya-zip
    TypeScript icon, indicating that this package has built-in type declarations

    0.2.1 • Public • Published

    ya-zip

    npm version

    Yet another zip utility for packaging and compressing a file or a directory

    Installation

    $ npm install ya-zip

    Usage

    const { zip, zipAsync, zipSync } = require('ya-zip');
    
    const src = path.resolve(__dirname, 'foo');
    const dest = path.resolve(__dirname, 'foo.zip');
    
    zipSync(src, dest);
    
    zip(src, dest, (err) => {
      if (err) throw err;
      console.log('Done!');
    });
    
    (async () => {
      await zipAsync(src, dest);
      console.log('Done!');
    })();

    API

    zip(source, destination[, options], callback)

    Zip a file or a directory.

    • source <string> Sets the path of a file or a directory to zip.
    • destination <string> Sets the path of the destination file.
    • options <Object> See node-archive ZipOptions
      • comment <string> Sets the zip archive comment.
      • forceLocalTime <boolean> Forces the archive to contain local file times instead of UTC.
      • forceZip64 <boolean> Forces the archive to contain ZIP64 headers.
      • store <boolean> Sets the compression method to STORE.
      • zlib <Object> Passed to zlib to control compression.
    • callback <Function>

    zipAsync(source, destination[, options])

    Promisified zip.

    zipSync(source, destination[, options])

    Synchronous zip.

    License

    MIT

    Why not cross-zip?

    cross-zip-cli (based on cross-zip) has inconsistent behaviors on different platforms.

    $ cross-zip ./src src.zip

    This will create a zip file contains a src folder on macOS/Linux (which based on Info-ZIP's zip utility).

    > cross-zip .\src src.zip

    But this command will create a zip file without a src folder on Windows (which based on .Net API).

    Note: ya-zip will not create the redundant folder.

    See also

    Keywords

    Install

    npm i ya-zip

    DownloadsWeekly Downloads

    1

    Version

    0.2.1

    License

    MIT

    Unpacked Size

    9.07 kB

    Total Files

    5

    Last publish

    Collaborators

    • dearke