Skip to content

Commit

Permalink
Merge pull request #172 from jrcryer/top-level-directories
Browse files Browse the repository at this point in the history
Fixes #170 - allow top level folders to be references by '**'
  • Loading branch information
shama committed Feb 2, 2016
2 parents cf9b122 + b31948c commit 049afa4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ module.exports = function(grunt) {
{expand: true, cwd: 'test/fixtures/', src: ['**/*']}
]
},
zipWithFolders: {
options: {
archive: 'tmp/compress_test_folder.zip'
},
files: [
{expand: true, cwd: 'test/fixtures/', src: ['**'], dest: './'}
]
},
tar: {
options: {
archive: 'tmp/compress_test_files.tar'
Expand Down
2 changes: 1 addition & 1 deletion tasks/lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ module.exports = function(grunt) {
var internalFileName = isExpandedPair ? file.dest : exports.unixifyPath(path.join(file.dest || '', srcFile));

// check if internal file name is not a dot, should not be present in an archive
if (internalFileName === '.') {
if (internalFileName === '.' || internalFileName === './') {
return;
}

Expand Down
20 changes: 20 additions & 0 deletions test/compress_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@ exports.compress = {
test.done();
});
},
zipWithFolder: function(test) {
test.expect(1);
var expected = [
'folder_one/', 'folder_one/one.css', 'folder_one/one.js',
'folder_two/', 'folder_two/two.css', 'folder_two/two.js',
'test.css', 'test.js'
];
var actual = [];
var parse = unzip.Parse();
fs.createReadStream(path.join('tmp', 'compress_test_folder.zip')).pipe(parse);
parse.on('entry', function(entry) {
actual.push(entry.path);
});
parse.on('close', function() {
actual.sort();
expected.sort();
test.deepEqual(actual, expected, 'zip file should unzip and contain all of the expected files');
test.done();
});
},
tar: function(test) {
test.expect(1);
var expected = [
Expand Down

0 comments on commit 049afa4

Please sign in to comment.