just-zip
Version:
Just Zip both files and directories with ease
47 lines (35 loc) • 1.35 kB
Markdown
Just Zip
==================================
### by Alexander Polomoshnov
### released under [the MIT license](https://raw.github.com/polomoshnov/just-zip/master/LICENSE.txt)
*Just Zip* both files and directories with ease.
## Install
```bash
npm install just-zip
```
## Examples
```js
zip = require('just-zip')
filePath = 'C:\\Users\\Polomoshnov\\test.pdf'
filePath2 = '../lorem ipsum.txt'
dirPath = '../pdfs'
customZipFilePath = 'C:\\Users\\Polomoshnov\\files.zip'
zip(filePath, function (err, zipFilePath) {
if (err) return console.error('Failed to zip:', err)
console.log('Zipped one file into', zipFilePath)
})
zip([filePath, filePath2], function (err, zipFilePath) {
if (err) return console.error('Failed to zip:', err)
console.log('Zipped two files into', zipFilePath)
})
zip([filePath, filePath2, dirPath], function (err, zipFilePath) {
if (err) return console.error('Failed to zip:', err)
console.log('Zipped two files and one directory into', zipFilePath)
})
zip([filePath, filePath2, dirPath], customZipFilePath, function (err, zipFilePath) {
if (err) return console.error('Failed to zip:', err)
console.log('Zipped two files and one directory into', zipFilePath)
})
```
## Acknowledgment
*Just Zip* is built upon [node-archiver](https://github.com/archiverjs/node-archiver).