Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

onezip

coderaiser3.9kMIT6.1.1

pack and extract .zip archives with emitter

extract, zip, unzip, pack

readme

OneZip License NPM version Build Status Coverage Status

Pack and extract .zip archives with emitter.

Global

onezip could be installed global with

npm i onezip -g

And used this way:

Usage: onezip [filename]
Options:
  -h, --help      display this help and exit
  -v, --version   output version information and exit
  -p, --pack      pack files to archive
  -x, --extract   extract files from archive

Local

onezip could be used locally. It will emit event on every packed/extracted file. Good for making progress bars.

Install

npm i onezip --save

How to use?

pack(from, to, names)

  • from - string directory that would be packed
  • to - string or stream, name of archive
  • names - array of names in directory from that would be packed.
const onezip = require('onezip');
const path = require('node:path');
const cwd = process.cwd();
const name = 'pipe.tar.gz';
const from = `${cwd}/pipe-io`;
const to = path.join(cwd, name);

const pack = onezip.pack(from, to, ['LICENSE', 'README.md', 'package.json']);

pack.on('file', (name) => {
    console.log(name);
});

pack.on('start', () => {
    console.log('start packing');
});

pack.on('progress', (percent) => {
    console.log(`${percent}%`);
});

pack.on('error', (error) => {
    console.error(error);
});

pack.on('end', () => {
    console.log('done');
});

extract(from, to)

  • from - path to .zip archive
  • to - path to directory where files would be stored.
const onezip = require('onezip');
const path = require('node:path');
const cwd = process.cwd();
const name = 'pipe.zip';
const to = `${cwd}/pipe-io`;
const from = path.join(cwd, name);

const extract = onezip.extract(from, to);

extract.on('file', (name) => {
    console.log(name);
});

extract.on('start', (percent) => {
    console.log('extracting started');
});

extract.on('progress', (percent) => {
    console.log(`${percent}%`);
});

extract.on('error', (error) => {
    console.error(error);
});

extract.on('end', () => {
    console.log('done');
});

In case of starting example output should be similar to (but with additional events):

33%
67%
100%
done
  • Jag - Pack files and folders with tar and gzip.
  • Jaguar - Pack and extract .tar.gz archives with emitter.
  • Tar-to-zip - Convert tar and tar.gz archives to zip.

License

MIT

changelog

2024.12.04, v6.1.1

feature:

  • 753a1f5 onezip: yazl v3.3.1
  • db3b4c9 onezip: c8 v10.1.2
  • c5881c0 onezip: eslint v9.16.0
  • a197d37 onezip: eslint-plugin-putout v23.2.0
  • 33d23cb onezip: putout v36.15.0

2024.05.14, v6.1.0

feature:

  • fd7ac28 onezip: c8 v9.1.0
  • 86e7d0c onezip: yauzl v3.1.3

2024.02.01, v6.0.2

fix:

  • a038fe7 README

2024.02.01, v6.0.1

fix:

  • f22dd56 badges

2024.02.01, v6.0.0

feature:

  • 292a8c7 onezip: @cloudcmd/stub v4.0.1
  • ba717da onezip: @iocmd/wait v2.1.0
  • efe4707 onezip: madrun v10.0.1
  • 9524328 onezip: nodemon v3.0.3
  • 6f07e8e onezip: rimraf v5.0.5
  • a94a6d7 onezip: eslint v9.0.0-alpha.2
  • f899526 onezip: supertape v10.0.0
  • a7762de onezip: eslint-plugin-putout v22.3.1
  • 7bbcee6 onezip: eslint-plugin-n v16.6.2
  • d25afb6 onezip: putout v35.0.1
  • c52cab4 drop support of node < 18
  • d5b647f onezip: yargs-parser v21.1.1
  • a802882 onezip: glob v10.3.10

2021.01.05, v5.0.0

fix:

  • (onezip) entry goes file before directory (#7)

feature:

  • (onezip) drop support of node < 14
  • (package) rm mkdirp, use mkdir recursive insted
  • (package) putout v13.1.2

2020.12.27, v4.2.3

feature:

  • (package) putout v12.9.4
  • (package) eslint-plugin-putout v6.11.0
  • (package) madrun v8.2.0
  • (package) yargs-parser v20.2.4
  • (package) supertape v4.1.0

2020.08.13, v4.2.2

feature:

  • (package) yargs-parser v19.0.1

2020.06.24, v4.2.1

fix:

  • (onezip) non closed zip file on windows: use yaulz autoClose=true option (#5)

feature:

  • (package) eslint-plugin-putout v5.0.0
  • (package) @cloudcmd/stub v3.1.0
  • (package) eslint v7.3.1
  • (package) madrun v7.0.0
  • (package) supertape v2.0.1
  • (package) putout v9.0.0

2020.05.03, v4.2.0

feature:

  • (onezip) superfind
  • (onezip) simplify findFiles

2020.04.23, v4.1.0

fix:

  • (onezip) revert end on abort

feature:

  • (onezip) asyncify

2020.04.23, v4.0.5

fix:

  • (onezip) do not send end, when error

feature:

  • (package) yargs-parser v18.1.3

2020.02.26, v4.0.4

feature:

  • (package) try-to-catch v3.0.0

2020.02.20, v4.0.3

feature:

  • (package) eslint-plugin-node v11.0.0
  • (package) yargs-parser v17.0.0
  • (package) nyc v15.0.0
  • (package) mkdirp v1.0.3
  • (package) madrun v5.0.1
  • (package) eslint-plugin-putout v3.0.0
  • (package) putout v7.3.1
  • (package) nodemon v2.0.2
  • (package) madrun v4.1.1

2019.10.27, v4.0.2

feature:

  • (package) yargs-parser v16.0.0

2019.10.16, v4.0.1

feature:

  • (package) try-to-catch v2.0.0

2019.10.16, v4.0.0

feature:

  • (onezip) drop support of node < 10
  • (package) yargs-parser v15.0.0

2019.09.18, v3.1.2

feature:

  • (package) yargs-parser v14.0.0
  • (package) rimraf v3.0.0
  • (onezip) madrun
  • (package) pipe-io v4.0.0
  • (package) nyc v14.1.1
  • (package) eslint v6.4.0

2018.10.08, v3.1.1

feature:

  • (package) yargs-parser v11.0.0
  • (package) rm unused itchy

2018.10.03, v3.1.0

feature:

  • (pack) callback -> async

2018.09.28, v3.0.0

feature:

  • (package) redrun v7.0.0
  • (package) nyc v13.0.1
  • (package) eslint v5.6.0
  • (package) drop support of node < 8

2018.05.08, v2.0.2

feature:

  • (package) findit -> findit2

2018.05.02, v2.0.1

fix:

  • (package) bin: rm legacy

2018.05.02, v2.0.0

feature:

  • (package) pipe-io v3.0.0
  • (travis) add node v10
  • (onezip) drop support of node < 4

2018.04.20, v1.0.14

feature:

  • (package) yargs-parser v10.0.0
  • (package) redrun v6.0.0

2018.03.05, v1.0.13

feature:

  • (package) yargs-parser v9.0.2

2017.10.05, v1.0.12

feature:

  • (package) babel-preset-es2015 -> babel-preset-env
  • (package) yargs-parser v8.0.0
  • (package) coveralls v3.0.0

2017.08.29, v1.0.11

feature:

  • (package) pump -> pipe-io

2017.08.28, v1.0.10

fix:

  • (onezip) Invalid central directory file header signature: pipe-io -> pump

2017.08.28, v1.0.9

fix:

  • (onezip) do not take into account the "to" property (#1)

feature:

  • (gitignore) add package-lock.json
  • (package) eslint v4.0.0
  • (package) nyc v11.0.2

2017.05.10, v1.0.8

feature:

  • (package) yargs-parser v7.0.0

2017.04.24, v1.0.7

feature:

  • (onezip) async.eachSeries -> itchy

2017.02.20, v1.0.6

feature:

  • (package) yargs-parser v5.0.0
  • (package) nyc v10.0.0

2016.11.17, v1.0.5

fix:

  • (onezip) pack/extract: slash at the end of from/to

feature:

  • (package) nyc v9.0.1

2016.11.08, v1.0.4

feature:

  • (package) pipe-io v2.0.1

2016.11.03, v1.0.3

feature:

  • (onezip) no need in "wasError" check

2016.11.03, v1.0.2

fix:

  • (jaguar) inheritance from EventEmitter

feature:

  • (travis) add lint, coverage
  • (travis) node_js: 6, 7

2016.11.01, v1.0.1

feature:

  • (package) yargs-parser v4.0.2