forked from EvanOxfeld/node-unzip
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from ZJONSSON/open-extract
Add `Open.extract` method
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 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
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
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
|
||
var test = require('tap').test; | ||
var path = require('path'); | ||
var temp = require('temp'); | ||
var dirdiff = require('dirdiff'); | ||
var unzip = require('../'); | ||
|
||
|
||
test("extract compressed archive with open.file.extract", function (t) { | ||
var archive = path.join(__dirname, '../testData/compressed-standard/archive.zip'); | ||
|
||
temp.mkdir('node-unzip-2', function (err, dirPath) { | ||
if (err) { | ||
throw err; | ||
} | ||
unzip.Open.file(archive) | ||
.then(function(d) { | ||
return d.extract({path: dirPath}); | ||
}) | ||
.then(function() { | ||
dirdiff(path.join(__dirname, '../testData/compressed-standard/inflated'), dirPath, { | ||
fileContents: true | ||
}, function (err, diffs) { | ||
if (err) { | ||
throw err; | ||
} | ||
t.equal(diffs.length, 0, 'extracted directory contents'); | ||
t.end(); | ||
}); | ||
}); | ||
|
||
}); | ||
}); |