Skip to content

Commit

Permalink
added additional field to methods for path to 7z binary
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechsTech committed Jan 22, 2018
1 parent 4ae6f8f commit e13d602
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 26 deletions.
13 changes: 6 additions & 7 deletions lib/add.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
'use strict';
var path = require('path');
var when = require('when');
var omit = require('object.omit');
var u = {
files : require('../util/files'),
run : require('../util/run'),
switches: require('../util/switches'),
path : require('../util/path'),
path : require('../util/path')
};

/**
Expand All @@ -20,19 +19,19 @@ var u = {
* @reject {Error} The error as issued by 7-Zip.
*/

module.exports = function (archive, files, options) {
module.exports = function (archive, files, optionspath, options) {
// Check options for `path` to pass path to binary to be parsed by `run`.
var command = u.path(options);
var optionsnopath = omit(options, 'path');
var command = u.path(optionspath);
if (options == null) var options = optionspath;
return when.promise(function (resolve, reject, progress) {

// Convert array of files into a string if needed.
files = u.files(files);

command += ' a "' + archive + '" ' + files;
command += ' a "' + archive + '" ' + files;

// Start the command
u.run(command, optionsnopath)
u.run(command, options)

// When a stdout is emitted, parse each line and search for a pattern. When
// the pattern is found, extract the file (or directory) name from it and
Expand Down
8 changes: 6 additions & 2 deletions lib/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var u = {
files : require('../util/files'),
run : require('../util/run'),
switches: require('../util/switches'),
path : require('../util/path')
};

/**
Expand All @@ -15,14 +16,17 @@ var u = {
* @resolve {array} Arguments passed to the child-process.
* @reject {Error} The error as issued by 7-Zip.
*/
module.exports = function (archive, files, options) {
module.exports = function (archive, files, optionspath, options) {
// Check options for `path` to pass path to binary to be parsed by `run`.
var command = u.path(optionspath);
if (options == null) var options = optionspath;
return when.promise(function (resolve, reject) {

// Convert array of files into a string if needed.
files = u.files(files);

// Create a string that can be parsed by `run`.
var command = '7z d "' + archive + '" ' + files;
command += ' d "' + archive + '" ' + files;

// Start the command
u.run(command, options)
Expand Down
10 changes: 7 additions & 3 deletions lib/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ var path = require('path');
var when = require('when');
var u = {
run : require('../util/run'),
switches: require('../util/switches')
switches: require('../util/switches'),
path : require('../util/path')
};

/**
Expand All @@ -16,11 +17,14 @@ var u = {
* @progress {array} Extracted files and directories.
* @reject {Error} The error as issued by 7-Zip.
*/
module.exports = function (archive, dest, options) {
module.exports = function (archive, dest, optionspath, options) {
// Check options for `path` to pass path to binary to be parsed by `run`.
var command = u.path(optionspath);
if (options == null) var options = optionspath;
return when.promise(function (resolve, reject, progress) {

// Create a string that can be parsed by `run`.
var command = '7z e "' + archive + '" -o"' + dest + '" ';
command += ' e "' + archive + '" -o"' + dest + '" ';

// Start the command
u.run(command, options)
Expand Down
10 changes: 7 additions & 3 deletions lib/extractFull.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ var path = require("path");
var when = require("when");
var u = {
run: require("../util/run"),
switches: require("../util/switches")
switches: require("../util/switches"),
path : require('../util/path')
};

/**
Expand All @@ -16,10 +17,13 @@ var u = {
* @progress {array} Extracted files and directories.
* @reject {Error} The error as issued by 7-Zip.
*/
module.exports = function(archive, dest, options) {
module.exports = function(archive, dest, optionspath, options) {
// Check options for `path` to pass path to binary to be parsed by `run`.
var command = u.path(optionspath);
if (options == null) var options = optionspath;
return when.promise(function(resolve, reject, progress) {
// Create a string that can be parsed by `run`.
var command = '7z x "' + archive + '" -o"' + dest + '" ';
command += ' x "' + archive + '" -o"' + dest + '" ';

// Start the command
u
Expand Down
10 changes: 7 additions & 3 deletions lib/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ var path = require("path");
var when = require("when");
var u = {
run: require("../util/run"),
switches: require("../util/switches")
switches: require("../util/switches"),
path : require('../util/path')
};

/**
Expand All @@ -15,15 +16,18 @@ var u = {
* @resolve {Object} Tech spec about the archive.
* @reject {Error} The error as issued by 7-Zip.
*/
module.exports = function(archive, options) {
module.exports = function(archive, optionspath, options) {
// Check options for `path` to pass path to binary to be parsed by `run`.
var command = u.path(optionspath);
if (options == null) var options = optionspath;
return when.promise(function(resolve, reject, progress) {
var spec = {};
/* jshint maxlen: 130 */
var regex = /(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ([\.DA]+)\s+(\d+)\s*(?:\d+)\s+(\S+?\.\S+)/;
/* jshint maxlen: 80 */

// Create a string that can be parsed by `run`.
var command = '7z l "' + archive + '" ';
command += ' l "' + archive + '" ';

var buffer = ""; //Store imcomplete line of a progress data.
// Start the command
Expand Down
10 changes: 7 additions & 3 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ var path = require('path');
var when = require('when');
var u = {
run : require('../util/run'),
switches: require('../util/switches')
switches: require('../util/switches'),
path : require('../util/path')
};

/**
Expand All @@ -15,11 +16,14 @@ var u = {
* @progress {array} Extracted files and directories.
* @reject {Error} The error as issued by 7-Zip.
*/
module.exports = function (archive, options) {
module.exports = function (archive, optionspath, options) {
// Check options for `path` to pass path to binary to be parsed by `run`.
var command = u.path(optionspath);
if (options == null) var options = optionspath;
return when.promise(function (resolve, reject, progress) {

// Create a string that can be parsed by `run`.
var command = '7z t "' + archive + '"';
command += ' t "' + archive + '"';

// Start the command
u.run(command, options)
Expand Down
10 changes: 7 additions & 3 deletions lib/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ var path = require('path');
var when = require('when');
var u = {
run: require('../util/run'),
switches : require('../util/switches')
switches : require('../util/switches'),
path : require('../util/path')
};

/**
Expand All @@ -16,11 +17,14 @@ var u = {
* @progress {array} Listed files and directories.
* @reject {Error} The error as issued by 7-Zip.
*/
module.exports = function (archive, files, options) {
module.exports = function (archive, files, optionspath, options) {
// Check options for `path` to pass path to binary to be parsed by `run`.
var command = u.path(optionspath);
if (options == null) var options = optionspath;
return when.promise(function (resolve, reject, progress) {

// Create a string that can be parsed by `run`.
var command = '7z u "' + archive + '" "' + files + '"';
command += ' u "' + archive + '" "' + files + '"';

// Start the command
u.run(command, options)
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
"homepage": "https://github.com/quentinrossetti/node-7zip.git",
"dependencies": {
"when": "^3.7.8",
"cross-spawn": "^5.1.0",
"object.omit": "^3.0.0"
"cross-spawn": "^5.1.0"
},
"devDependencies": {
"chai": "^3.5.0",
Expand Down

0 comments on commit e13d602

Please sign in to comment.