forked from bower/decompress-zip
-
Notifications
You must be signed in to change notification settings - Fork 0
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 bower#32 from szwacz/file-mode-preservation
Added file mode preservation
- Loading branch information
Showing
10 changed files
with
197 additions
and
50 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
Binary file not shown.
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,53 @@ | ||
// This script generates zip files inside this folder. | ||
|
||
'use strict'; | ||
|
||
var jetpack = require('fs-jetpack'); | ||
var archiver = require('archiver'); | ||
|
||
var mainDir = jetpack.cwd(__dirname); | ||
|
||
// ------------------------------------------------------- | ||
// Generate files and folders which we next will compress | ||
// ------------------------------------------------------- | ||
|
||
var extractedDir = mainDir.dir('extracted', { empty: true, mode: '755' }); | ||
extractedDir | ||
.dir('dir1', { mode: '755' }) | ||
.cwd('..') | ||
.dir('dir2', { mode: '711' }) | ||
.cwd('..') | ||
.file('file1', { content: 'abc', mode: '755' }) | ||
.file('file2', { content: 'xyz', mode: '711' }); | ||
|
||
// ------------------------------------------------------- | ||
// Generate spec file | ||
// ------------------------------------------------------- | ||
|
||
// Generate spec file to which we can later compare | ||
// our extracted stuff during tests. | ||
var spec = mainDir.inspectTree('extracted', { checksum: 'sha1', mode: true }); | ||
mainDir.write('spec.json', spec, { jsonIndent: 2 }); | ||
|
||
// ------------------------------------------------------- | ||
// Compress to zip files | ||
// ------------------------------------------------------- | ||
|
||
var compress = function (dest, useStore) { | ||
var output = mainDir.createWriteStream(dest); | ||
output.on('close', function () { | ||
console.log('Archive ' + dest + ' created.'); | ||
}); | ||
var archive = archiver('zip', { store: useStore }); | ||
archive.on('error', function (err){ | ||
console.log(err); | ||
}); | ||
archive.pipe(output); | ||
archive.bulk([ | ||
{ expand: true, cwd: extractedDir.path(), src: ['**'] } | ||
]); | ||
archive.finalize(); | ||
}; | ||
|
||
compress('store.zip', true); | ||
compress('deflate.zip', false); |
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,39 @@ | ||
{ | ||
"name": "extracted", | ||
"type": "dir", | ||
"mode": 16877, | ||
"size": 6, | ||
"children": [ | ||
{ | ||
"name": "dir1", | ||
"type": "dir", | ||
"mode": 16877, | ||
"size": 0, | ||
"children": [], | ||
"sha1": null | ||
}, | ||
{ | ||
"name": "dir2", | ||
"type": "dir", | ||
"mode": 16841, | ||
"size": 0, | ||
"children": [], | ||
"sha1": null | ||
}, | ||
{ | ||
"name": "file1", | ||
"type": "file", | ||
"size": 3, | ||
"sha1": "a9993e364706816aba3e25717850c26c9cd0d89d", | ||
"mode": 33261 | ||
}, | ||
{ | ||
"name": "file2", | ||
"type": "file", | ||
"size": 3, | ||
"sha1": "66b27417d37e024c46526c2f6d358a754fc552f3", | ||
"mode": 33225 | ||
} | ||
], | ||
"sha1": "ac6f83cc555959a5817f979deb9e845d4d6962d2" | ||
} |
Binary file not shown.
Binary file not shown.
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
Binary file not shown.
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