Skip to content

Commit

Permalink
fix: Add command uses codebase refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
q2s2t committed Oct 10, 2018
1 parent 40e6750 commit b7c6687
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions lib/commands.js
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
}

0 comments on commit b7c6687

Please sign in to comment.