Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-7z

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-7z - npm Package Compare versions

Comparing version 2.1.2 to 3.0.0

21

CHANGELOG.md

@@ -0,1 +1,22 @@

## 3.0.0 (2021-07-11)
#### BREAKING CHANGE
* Drop cross-spawn in favor of Node.js spawn
* feat: Do not build string switch with falsy values #102 ([b7f799c](https://github.com/quentinrossetti/node-7z/commit/b7f799c)), closes [#102](https://github.com/quentinrossetti/node-7z/issues/102)
* feat: Hides cmd on Windows #89 ([e955111](https://github.com/quentinrossetti/node-7z/commit/e955111)), closes [#89](https://github.com/quentinrossetti/node-7z/issues/89)
* ci: Ignore a test du to mismatch 7z versions ([48a74d6](https://github.com/quentinrossetti/node-7z/commit/48a74d6))
* test: Don't test dates because AppVeyor changes them ([f05d6e2](https://github.com/quentinrossetti/node-7z/commit/f05d6e2))
* test: Mark as executable (NTFS removed it) ([6e35dfe](https://github.com/quentinrossetti/node-7z/commit/6e35dfe))
* test: Remove redundant error code checking ([80f22f5](https://github.com/quentinrossetti/node-7z/commit/80f22f5))
* dist: VSCode workspace ([e91e7d4](https://github.com/quentinrossetti/node-7z/commit/e91e7d4))
* chore: Ignore .exe used for local testing ([1305071](https://github.com/quentinrossetti/node-7z/commit/1305071))
* chore(deps): bump glob-parent from 5.1.1 to 5.1.2 ([59f83ee](https://github.com/quentinrossetti/node-7z/commit/59f83ee))
* chore(deps): bump hosted-git-info from 2.8.8 to 2.8.9 ([f9746d0](https://github.com/quentinrossetti/node-7z/commit/f9746d0))
* chore(deps): bump lodash from 4.17.20 to 4.17.21 ([0bf9517](https://github.com/quentinrossetti/node-7z/commit/0bf9517))
* chore(deps): bump y18n from 4.0.0 to 4.0.1 ([f30d5b4](https://github.com/quentinrossetti/node-7z/commit/f30d5b4))
* doc: Fix options table parsing ([9e6ded4](https://github.com/quentinrossetti/node-7z/commit/9e6ded4))
* doc: Fix typos ([801a79b](https://github.com/quentinrossetti/node-7z/commit/801a79b))
* Fixed typo ([a16d499](https://github.com/quentinrossetti/node-7z/commit/a16d499))
## 2.1.2 (2020-10-11)

@@ -2,0 +23,0 @@

7

package.json
{
"name": "node-7z",
"version": "2.1.2",
"version": "3.0.0",
"description": "A Node.js wrapper for 7-Zip with platform binaries",

@@ -39,4 +39,3 @@ "main": "./src/main.js",

"dependencies": {
"cross-spawn": "^7.0.2",
"debug": "^4.1.1",
"debug": "^4.3.2",
"lodash.defaultsdeep": "^4.6.1",

@@ -51,3 +50,3 @@ "lodash.defaultto": "^4.14.0",

"devDependencies": {
"chai": "^4.2.0",
"chai": "^4.3.4",
"esm": "^3.2.25",

@@ -54,0 +53,0 @@ "fs-readdir-recursive": "^1.1.0",

@@ -17,4 +17,4 @@ <h1 align="center">node-7z</h1>

// myStream is an Readable stream
const myStream = Seven.extractFull('./archive.7z', './output/dir/', {
// myStream is a Readable stream
const myStream = Seven.extractFull('./archive.7z', './output/dir/', {
$progress: true

@@ -59,5 +59,5 @@ })

> - On Debian and Ubuntu install the p7zip-full package.
> - On Debian and Ubuntu install the p7zip-full package or use 7-Zip 21.02 alpha or higher
> - On Mac OSX use Homebrew `brew install p7zip`
> - On Windows get 7-Zip frome [7-Zip download page](https://www.7-zip.org/download.html).
> - On Windows get 7-Zip from [7-Zip download page](https://www.7-zip.org/download.html).
>

@@ -93,3 +93,3 @@ > By default the module calls the `7z` binary, it should be available in your

|-----------|--------------------|-------------|
| archive | `string` | Archive to create |
| archive | `string` | Archive to create |
| source | `string\|string[]` | Source files to add to the archive. Multiple sources can be given using an `Array` |

@@ -110,3 +110,3 @@ | [options] | `Object` | [Options object](#options). Can be omitted |

|-----------|--------------------|-------------|
| archive | `string` | Archive to target |
| archive | `string` | Archive to target |
| target | `string\|string[]` | Target files to remove from the archive. Multiple targets can be given using an `Array` |

@@ -125,3 +125,3 @@ | [options] | `Object` | [Options object](#options). Can be omitted |

|-----------|-------------------|-------------|
| archive | `string` | Archive to extract files from |
| archive | `string` | Archive to extract files from |
| output | `string` | Output directory |

@@ -143,3 +143,3 @@ | [options] | `Object` | [Options object](#options). Can be omitted |

|-----------|-------------------|-------------|
| archive | `string` | Archive to extract files from |
| archive | `string` | Archive to extract files from |
| output | `string` | Output directory |

@@ -191,3 +191,3 @@ | [options] | `Object` | [Options object](#options). Can be omitted |

|-----------|-------------------|-------------|
| archive | `string` | Archive to target |
| archive | `string` | Archive to target |
| target | `Array[string[]]` | Pair of target/new names files to remove rename. Multiple targets can be given using an `Array` |

@@ -225,3 +225,3 @@ | [options] | `Object` | [Options object](#options). Can be omitted |

|-----------|-------------------|-------------|
| archive | `string` | Archive to create |
| archive | `string` | Archive to create |
| source | `string\|string[]` | Source files to update from the file-system to the archive. Multiple sources can be given using an `Array` |

@@ -241,47 +241,47 @@ | [options] | `Object` | [Options object](#options). Can be omitted |

| Name | Type | Description | Switches |
|--------------------------|------------|-----------------------------------------------------------------------|----------|
| `alternateStreamExtract` | `boolean` | "Extract file as alternate stream, if there is ':' character in name" | `-snc` |
| `alternateStreamReplace` | `boolean` | Replace ':' character to '_' character in paths of alternate streams | `-snr` |
| `deleteFilesAfter` | `boolean` | Delete files after compression | `-sdel` |
| `fullyQualifiedPaths` | `boolean` | Usefully qualified file paths | `-spf` |
| `hardlinks` | `boolean` | Store hard links as links (WIM and TAR formats only) | `-snh` |
| `largePages` | `boolean` | Set Large Pages mode | `-spl` |
| `latestTimeStamp` | `boolean` | Set archive timestamp from the most recently modified file | `-stl` |
| `noArchiveOnFail` | `boolean` | Stop archive creating, if 7-Zip can't open some input file. | `-sse` |
| `noRootDuplication` | `boolean` | Eliminate duplication of root folder for extract command | `-spe` |
| `noWildcards` | `boolean` | Disable wildcard matching for file names | `-spd` |
| Name | Type | Description | Switches |
|--------------------------|------------|-----------------------------------------------------------------------|----------|
| `alternateStreamExtract` | `boolean` | "Extract file as alternate stream, if there is ':' character in name" | `-snc` |
| `alternateStreamReplace` | `boolean` | Replace ':' character to '_' character in paths of alternate streams | `-snr` |
| `deleteFilesAfter` | `boolean` | Delete files after compression | `-sdel` |
| `fullyQualifiedPaths` | `boolean` | Usefully qualified file paths | `-spf` |
| `hardlinks` | `boolean` | Store hard links as links (WIM and TAR formats only) | `-snh` |
| `largePages` | `boolean` | Set Large Pages mode | `-spl` |
| `latestTimeStamp` | `boolean` | Set archive timestamp from the most recently modified file | `-stl` |
| `noArchiveOnFail` | `boolean` | Stop archive creating, if 7-Zip can't open some input file. | `-sse` |
| `noRootDuplication` | `boolean` | Eliminate duplication of root folder for extract command | `-spe` |
| `noWildcards` | `boolean` | Disable wildcard matching for file names | `-spd` |
| `ntSecurity` | `boolean` | Store NT security | `-sni` |
| `sortByType` | `boolean` | Sort files by type while adding to solid 7z archive | `-mqs` |
| `openFiles` | `boolean` | Compress files open for writing | `-ssw` |
| `recursive` | `boolean` | Recurse subdirectories. For `-r0` usage see `raw` | `-r` |
| `symlinks` | `boolean` | Store symbolic links as links (WIM and TAR formats only) | `-snl` |
| `techInfo` | `boolean` | Show technical information | `-slt` |
| `timeStats` | `boolean` | Show execution time statistics | `-bt` |
| `toStdout` | `boolean` | Write data to stdout | `-so` |
| `yes` | `boolean` | Assume Yes on all queries | `-y` |
| `alternateStreamStore` | `boolean` | Store NTFS alternate Streams | `-sns` |
| `caseSensitive` | `boolean` | Set Sensitive Case mode | `-ssc` |
| `archiveNameMode` | `string` | Set Archive name mode | `-sa` |
| `archiveType` | `string` | Type of archive | `-t` |
| `cpuAffinity` | `string` | Set CPU thread affinity mask (hexadecimal number). | `-stm` |
| `excludeArchiveType` | `string` | Exclude archive type | `-stx` |
| `fromStdin` | `string` | Read data from StdIn | `-si` |
| `hashMethod` | `string` | Set hash function | `-scrc` |
| `listFileCharset` | `string` | Set charset for list files | `-scs` |
| `logLevel` | `string` | Set output log level | `-bb` |
| `multiBlockSize` | `string` | Creates multi-block xz archives of `[Size]m|g` block size | `-ms` |
| `outputDir` | `string` | Set Output directory | `-o` |
| `overwrite` | `string` | Overwrite mode | `-ao` |
| `password` | `string` | Set Password | `-p` |
| `sfx` | `string` | Create SFX archive | `-sfx` |
| `updateOptions` | `string` | Update options | `-u` |
| `workingDir` | `string` | Set Working directory | `-w` |
| `excludeArchive` | `string[]` | Exclude archive filenames | `-ax` |
| `exlude` | `string[]` | Exclude filenames | `-x` |
| `include` | `string[]` | Include filenames | `-i` |
| `includeArchive` | `string[]` | Include archive filenames | `-ai` |
| `method` | `string[]` | Set Compression Method | `-m` |
| `outputStreams` | `string[]` | Set output stream for output/error/progress | `-bs` |
| `volumes` | `string[]` | Create Volumes | `-v` |
| `openFiles` | `boolean` | Compress files open for writing | `-ssw` |
| `recursive` | `boolean` | Recurse subdirectories. For `-r0` usage see `raw` | `-r` |
| `symlinks` | `boolean` | Store symbolic links as links (WIM and TAR formats only) | `-snl` |
| `techInfo` | `boolean` | Show technical information | `-slt` |
| `timeStats` | `boolean` | Show execution time statistics | `-bt` |
| `toStdout` | `boolean` | Write data to stdout | `-so` |
| `yes` | `boolean` | Assume Yes on all queries | `-y` |
| `alternateStreamStore` | `boolean` | Store NTFS alternate Streams | `-sns` |
| `caseSensitive` | `boolean` | Set Sensitive Case mode | `-ssc` |
| `archiveNameMode` | `string` | Set Archive name mode | `-sa` |
| `archiveType` | `string` | Type of archive | `-t` |
| `cpuAffinity` | `string` | Set CPU thread affinity mask (hexadecimal number). | `-stm` |
| `excludeArchiveType` | `string` | Exclude archive type | `-stx` |
| `fromStdin` | `string` | Read data from StdIn | `-si` |
| `hashMethod` | `string` | Set hash function | `-scrc` |
| `listFileCharset` | `string` | Set charset for list files | `-scs` |
| `logLevel` | `string` | Set output log level | `-bb` |
| `multiBlockSize` | `string` | Creates multi-block xz archives of `[Size]m\|g` block size | `-ms` |
| `outputDir` | `string` | Set Output directory | `-o` |
| `overwrite` | `string` | Overwrite mode | `-ao` |
| `password` | `string` | Set Password | `-p` |
| `sfx` | `string` | Create SFX archive | `-sfx` |
| `updateOptions` | `string` | Update options | `-u` |
| `workingDir` | `string` | Set Working directory | `-w` |
| `excludeArchive` | `string[]` | Exclude archive filenames | `-ax` |
| `exclude` | `string[]` | Exclude filenames | `-x` |
| `include` | `string[]` | Include filenames | `-i` |
| `includeArchive` | `string[]` | Include archive filenames | `-ai` |
| `method` | `string[]` | Set Compression Method | `-m` |
| `outputStreams` | `string[]` | Set output stream for output/error/progress | `-bs` |
| `volumes` | `string[]` | Create Volumes | `-v` |

@@ -316,2 +316,12 @@ #### Special options

// hash: 'FEDC304F', size: 9 (only hash command)
// techInfo: Map(8) { (only list command with `techInfo` switch)
// 'Path' => 'DirHex/sub2/e825776890f2b',
// 'Size' => '9',
// 'Modified' => '2018-09-29 09:06:15',
// 'Attributes' => 'A_ -rw-r--r--',
// 'CRC' => 'FEDC304F',
// 'Encrypted' => '-',
// 'Method' => 'LZMA2:12',
// 'Block' => '0'
// }
// }

@@ -393,3 +403,3 @@ })

It's a base feature of `node-7z` and is required for the module to work as
It's a base feature of `node-7z` and is required for the module to work as
expected. A diffrent value should not be used.

@@ -396,0 +406,0 @@

@@ -33,2 +33,5 @@ // Copyright (c) 2014-2019, Quentin Rossetti <quentin.rossetti@gmail.com>

_options._command = command
if (options.techInfo) {
_options._command = 'listTechInfo'
}
_options._target = [target, options.$cherryPick]

@@ -35,0 +38,0 @@ return main(_options)

@@ -52,3 +52,3 @@ // Copyright (c) 2014-2019, Quentin Rossetti <quentin.rossetti@gmail.com>

// End of HEADERS can be easy to detect with list and hash commands that
// End of HEADERS can be easy to detected with list and hash commands that
// outputs a `---- -- ----` line, but in symbol commands the end of HEADERS

@@ -55,0 +55,0 @@ // can only be detected when the line match a BODY data: In such cases the

@@ -69,3 +69,7 @@ // Copyright (c) 2014-2019, Quentin Rossetti <quentin.rossetti@gmail.com>

string: flag => {
return `-${flag.cli}${flag.value}`
if (flag.value) {
return `-${flag.cli}${flag.value}`
} else {
return ''
}
},

@@ -72,0 +76,0 @@ stringArray: flag => {

@@ -16,3 +16,3 @@ // Copyright (c) 2014-2019, Quentin Rossetti <quentin.rossetti@gmail.com>

const debug = require('debug')('node-7z')
const spawn = require('cross-spawn')
const spawn = require('child_process').spawn
const { Readable } = require('stream')

@@ -46,3 +46,2 @@ const { STAGE_HEADERS } = require('./references')

seven._stage = STAGE_HEADERS
seven._spawnOptions = options.$spawnOptions
seven._matchBodyData = Parser.fetch(options._command, 'bodyData')

@@ -73,3 +72,6 @@ seven._matchEndOfHeaders = Parser.fetch(options._command, 'endOfHeaders')

const run = stream => {
const spawnOptions = Object.assign({ detached: true }, stream._spawnOptions)
const spawnOptions = Object.assign({
detached: true,
windowsHide: true
}, stream._spawnOptions)
stream._childProcess = spawn(stream._bin, stream._args, spawnOptions)

@@ -76,0 +78,0 @@ return stream

@@ -24,8 +24,10 @@ // Copyright (c) 2014-2019, Quentin Rossetti <quentin.rossetti@gmail.com>

const fromBuffer = (seven, buffer) => {
const lines = buffer.toString().split(LINE_SPLIT)
if (seven._lastLinePartial) {
lines[0] = seven._lastLinePartial.concat(lines[0])
buffer = Buffer.concat([seven._lastLinePartial, buffer])
}
const newLastLine = lines[lines.length - 1]
const lines = buffer.toString().split(LINE_SPLIT)
const offset = buffer.lastIndexOf('\n') + 1
const newLastLine = buffer.slice(offset)
const isNewLastLineComplete = (newLastLine.indexOf('\n') === newLastLine.length - 1)
if (!isNewLastLineComplete) {

@@ -32,0 +34,0 @@ seven._lastLinePartial = newLastLine

@@ -16,3 +16,3 @@ // Copyright (c) 2014-2019, Quentin Rossetti <quentin.rossetti@gmail.com>

const normalizePath = require('normalize-path')
const { INFOS, BODY_PROGRESS, BODY_SYMBOL_FILE, BODY_HASH, INFOS_SPLIT, END_OF_STAGE_HYPHEN } = require('./regexp')
const { INFOS, BODY_PROGRESS, BODY_SYMBOL_FILE, BODY_HASH, INFOS_SPLIT, INFOS_PATH, END_OF_STAGE_HYPHEN, END_OF_TECH_INFOS_HEADERS } = require('./regexp')
const { SYMBOL_OPERATIONS } = require('./references')

@@ -62,7 +62,14 @@

return line
} else {
return null
}
return null
}
function matchEndOfHeadersTechInfo (stream, line) {
const isEnd = END_OF_TECH_INFOS_HEADERS.test(line)
if (isEnd) {
return line
}
return null
}
// Progress as a percentage is only displayed to stdout when the `-bsp1` switch

@@ -151,2 +158,42 @@ // is specified. Progress can has several forms:

// List command with -slt switch. This commands outputs multiples lines per
// file. E.g.:
// Path = DirImages/LICENSE
// Size = 37
// Packed Size = 18292718
// Modified = 2018-10-02 21:45:49
// Attributes = A_ -rw-r--r--
// CRC = F303F60C
// Encrypted = -
// Method = LZMA2:24
// Block = 0
// *Path* is the first and *Block* is the last so we use that to mark the end
// of data. The end of the output is marked by 2 empty lines
function matchBodyTechInfo (stream, line) {
if (!stream._lastLines) {
stream._lastLines = ['', '']
}
stream._lastLines[1] = stream._lastLines[0]
stream._lastLines[0] = line
if (isEmpty(line)) {
if (isEmpty(stream._lastLines[1])) {
return null
}
return {
file: stream._lastTechInfo.get('Path'),
techInfo: stream._lastTechInfo
}
}
const match = line.match(INFOS)
if (match) {
if (match.groups.property === 'Path') {
stream._lastTechInfo = new Map()
match.groups.value = normalizePath(match.groups.value)
}
stream._lastTechInfo.set(match.groups.property, match.groups.value)
}
return null
}
// This function determines if the end of the body section has been reached,

@@ -224,2 +271,8 @@ // an empty line is emited by 7z at the end of the body, so this function

},
listTechInfo: {
bodyData: matchBodyTechInfo,
endOfHeaders: matchEndOfHeadersTechInfo,
endOfBody: matchEndOfHeadersHyphen,
dataType: 'showTechInfo'
},
rename: {

@@ -251,2 +304,3 @@ bodyData: matchBodySymbol,

matchEndOfHeadersHyphen,
matchEndOfHeadersTechInfo,
matchProgress,

@@ -256,4 +310,5 @@ matchBodySymbol,

matchBodyHash,
matchBodyTechInfo,
matchEndOfBodySymbol,
fetch
}

@@ -54,3 +54,3 @@ // Copyright (c) 2014-2019, Quentin Rossetti <quentin.rossetti@gmail.com>

{ type: 'stringArray', api: 'excludeArchive', cli: 'ax' }, // Exclude archive filenames
{ type: 'stringArray', api: 'exlude', cli: 'x' }, // Exclude filenames
{ type: 'stringArray', api: 'exclude', cli: 'x' }, // Exclude filenames
{ type: 'stringArray', api: 'include', cli: 'i' }, // Include filenames

@@ -83,2 +83,3 @@ { type: 'stringArray', api: 'includeArchive', cli: 'ai' }, // Include archive filenames

list: 'l',
listTechInfo: 'l',
rename: 'rn',

@@ -85,0 +86,0 @@ test: 't',

@@ -20,3 +20,5 @@ // Copyright (c) 2014-2019, Quentin Rossetti <quentin.rossetti@gmail.com>

const END_OF_STAGE_HYPHEN = new RegExp('^(-+ +)+-+$')
const END_OF_TECH_INFOS_HEADERS = new RegExp('^----------$')
const INFOS = new RegExp('^(?<property>.+?)(?<separator>( = )|(: +))(?<value>.+)$')
const INFOS_PATH = new RegExp('^Path = (?<path>.+)$')
const INFOS_SPLIT = new RegExp(', +# ')

@@ -31,5 +33,7 @@ const ERROR = new RegExp('(?<level>WARNING|ERROR): (?<message>.*)(\r\n)?(\n)?', 'i')

END_OF_STAGE_HYPHEN,
END_OF_TECH_INFOS_HEADERS,
INFOS,
INFOS_PATH,
INFOS_SPLIT,
ERROR
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc