https://github.com/rdarida/cross-7zip
https://github.com/rdarida/cross-7zip
7-zip cross-platform linux macos windows
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/rdarida/cross-7zip
- Owner: rdarida
- License: mit
- Created: 2025-01-19T18:08:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-26T15:42:40.000Z (over 1 year ago)
- Last Synced: 2025-01-26T16:26:01.246Z (over 1 year ago)
- Language: TypeScript
- Size: 8.83 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README

# cross-7zip
Cross-platform 7-Zip for Node.js
## Installation
Install **cross-7zip** via [npm](https://www.npmjs.com/package/cross-7zip).
```sh
npm i cross-7zip
```
or
```sh
npm i -g cross-7zip
```
## API
### `SevenZip`
A wrapper class for creating 7-Zip archives using the command-line tool.
[Example](https://rdarida.github.io/cross-7zip/classes/SevenZip.html#example)
### `SevenUnzip`
A wrapper class for extracting files from a 7-Zip archive using the command-line tool.
[Example](https://rdarida.github.io/cross-7zip/classes/SevenUnzip.html#example)
### `sevenZip`
Compresses multiple files into a zipped file **asynchronously**.
[Example](https://rdarida.github.io/cross-7zip/functions/sevenZip.html#example)
### `sevenUnzip`
Extracts files from a specified zipped file **asynchronously**.
[Example](https://rdarida.github.io/cross-7zip/functions/sevenUnzip.html#example)
### `sevenZipSync`
Compresses multiple files into a zipped file **synchronously**.
[Example](https://rdarida.github.io/cross-7zip/functions/sevenZipSync.html#example)
### `sevenUnzipSync`
Extracts files from a specified zipped file **synchronously**.
[Example](https://rdarida.github.io/cross-7zip/functions/sevenUnzipSync.html#example)
## CLI Tool Usage
This package also includes a CLI tool for quick and simple operations with 7-Zip.
Below are some examples of how to use it:
### Installation
Make sure the package is installed globally to access the CLI tool:
```bash
npm install -g cross-7zip
```
### Commands
**Create an Archive**
To compress files or directories into an archive, use the `zip` command:
```bash
seven zip
```
**Extract Files from an Archive**
To extract files from an archive, use the `unzip` command:
```bash
seven unzip [destination]
```
### Examples
**Create `example.7z` from `file1.txt` `folder`**
```bash
seven zip example.7z file1.txt folder
```
**Extract Files from the `example.7z` into the `ouput` folder**
```bash
seven unzip example.7z ouput
```
## Supported Platforms and Architectures
This library relies on the 7-Zip executables, which support the following
platforms and architectures:
- **Windows**: `arm64`, `x86`, `x64`
- **macOS**: `arm64`, `x86, x64`
- **Linux**: `arm`, `arm64`, `x86`, `x64`
For details, click [here](https://github.com/rdarida/cross-7zip/blob/main/7zip/README.md).
Resources
- [Documentation](https://rdarida.github.io/cross-7zip/)
- [7-Zip](https://www.7-zip.org/)
- [execFileSync](https://nodejs.org/api/child_process.html#child_process_child_process_execfilesync_file_args_options)
- **Windows**
* [Compress-Archive](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.archive/compress-archive?view=powershell-7.4&viewFallbackFrom=powershell-7.1)
* [Expand-Archive](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.archive/expand-archive?view=powershell-7.4&viewFallbackFrom=powershell-7.1)
- **Unix**
* [zip](https://linux.die.net/man/1/zip)
* [unzip](https://linux.die.net/man/1/unzip)