Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
q2s2t committed Oct 23, 2014
2 parents c4bd3e2 + edd5d15 commit 073bbb0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
11 changes: 10 additions & 1 deletion test/method.Zip.extractFull.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var extractFull = require('../lib/extractFull');

describe('Method: `Zip.extractFull`', function () {

afterEach(function () { fs.removeSync('.tmp/test'); });
//afterEach(function () { fs.removeSync('.tmp/test'); });

it('should return an error on 7z error', function (done) {
extractFull('test/nothere.7z', '.tmp/test')
Expand Down Expand Up @@ -54,5 +54,14 @@ describe('Method: `Zip.extractFull`', function () {
done();
});
});

it('should work with spaces in both source and destination', function (done) {
fs.copySync('test/zip.7z','.tmp/test/Folder From/Folder A/Folder B/Folder C/zip file.7z');
extractFull('.tmp/test/Folder From/Folder A/Folder B/Folder C/zip file.7z','.tmp/test/Folder To/Folder D/Folder E/Folder F')
.then(function () {
expect(fs.existsSync('.tmp/test/Folder To/Folder D/Folder E/Folder F/zip')).to.be.eql(true);
done();
});
});

});
19 changes: 14 additions & 5 deletions util/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
var os = require('os');
var spawn = require('win-spawn');
var when = require('when');
var path = require('path');

/**
* @promise Run
Expand Down Expand Up @@ -37,11 +38,19 @@ module.exports = function (command) {
}
};

// Run the filter twice. By splicing the array in the function above the
// filter does not run on the item just after one that is being removed.
args.forEach(filterSpaces);
args.forEach(filterSpaces);

// Run the filter for each space. By splicing the array in the function
// above the filter does not run on the item just after one that is being
// removed.
for (var i = 0; i < args.length; i++) {
args.forEach(filterSpaces);
}

// Normalize pathes before passing them to 7-Zip.
if (args.length > 1) {
args[1] = path.normalize(args[1]);
args[2] = path.normalize(args[2]);
}

// When an stdout is emitted, parse it. If an error is detected in the body
// of the stdout create an new error with the 7-Zip error message as the
// error's message. Otherwise progress with stdout message.
Expand Down

0 comments on commit 073bbb0

Please sign in to comment.