node-7z
A Node.js wrapper for 7-Zip
Usage
I chose to use Promises in this library. API is consistent with standard use:
var Zip = require('node-7z');
var myTask = new Zip();
myTask.extractFull('myArchive.7z', 'destination', { p: 'myPassword' })
.progress(function (files) {
console.log('Some files are extracted: %s', files);
});
.then(function () {
console.log('Extracting done!');
});
.catch(function (err, code) {
console.error('7-Zip exit with code %i', code);
console.error(err);
});
Installation
You must have the 7za
executable available in your PATH or in the same
directory of your package.json
file.
On Debian an Ubuntu install the p7zip-full
package.
On Windows use the 7za.exe
(link here)
binary.
npm install --save node-7z
API
See the 7-Zip documentation
for the full list of usages and options (switches).
Add: Zip.add
Arguments
archive
Path to the archive you want to create.files
The file list to add.options
An object of options (7-Zip switches).
Progress
files
A array of all the extracted files AND directories. The /
character is used as a path separator on every platform.
Error
Delete: Zip.delete
Arguments
archive
Path to the archive you want to delete files from.files
The file list to delete.options
An object of options (7-Zip switches).
Error
Arguments
archive
The path to the archive you want to extract.dest
Where to extract the archive.options
An object of options.
Progress
files
A array of all the extracted files AND directories. The /
character is used as a path separator on every platform.
Error
Arguments
archive
The path to the archive you want to extract.dest
Where to extract the archive (creates folders for you).options
An object of options.
Progress
files
A array of all the extracted files AND directories. The /
character is used as a path separator on every platform.
Error
List contents of archive: Zip.list
Arguments
archive
The path to the archive you want to analyse.options
An object of options.
Progress
files
A array of objects of all the extracted files AND directories.
The /
character is used as a path separator on every platform. Object's
properties are: date
, attr
, size
and name
.
Fulfill
spec
An object of tech spec about the archive. Properties are: path
,
type
, method
, physicalSize
and headersSize
(Some of them may be
missing with non-7z archives).
Error
Test integrity of archive: Zip.test
Arguments
archive
The path to the archive you want to analyse.options
An object of options.
Progress
files
A array of all the extracted files AND directories. The /
character is used as a path separator on every platform.
Error
Update: Zip.update
Arguments
archive
Path to the archive you want to update.files
The file list to update.options
An object of options (7-Zip switches).
Progress
files
A array of all the extracted files AND directories. The /
character is used as a path separator on every platform.
Error
With :heart: from quentinrossetti