-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add command uses codebase refactoring
- Loading branch information
Showing
1 changed file
with
4 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,13 @@ | ||
import { SevenZipStream } from './stream.js' | ||
import { listenStdEvents } from './listeners.js' | ||
import { matchPropsColon, matchPropsEquals, matchProgress } from './parser.js' | ||
|
||
/** | ||
* Add command | ||
* @param archive {String} Path to the archive | ||
* @param source {String|Array} Source to add | ||
* @param options {Object} An object of acceptable options to 7za bin. | ||
*/ | ||
export function add (archive, source, options) { | ||
const opts = Object.assign({}, options) | ||
opts._commandArgs = ['a'] | ||
opts._commandArgs.push(archive, source) | ||
opts._parser = 'symbolFile' | ||
opts._matchHeaders = matchPropsEquals | ||
opts._matchFiles = matchProgress | ||
opts._matchFooters = matchPropsColon | ||
const stream = new SevenZipStream(opts) | ||
listenStdEvents(stream) | ||
return stream | ||
} | ||
|
||
export function test (archive, options) { | ||
const opts = Object.assign({}, options) | ||
opts._commandArgs = ['t'] | ||
opts._commandArgs.push(archive) | ||
opts._parser = 'symbolFile' | ||
const stream = new SevenZipStream(opts) | ||
listenStdEvents(stream) | ||
return stream | ||
} |