diff --git a/Gruntfile.js b/Gruntfile.js index f3dff69..3a94db3 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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' diff --git a/tasks/lib/compress.js b/tasks/lib/compress.js index 61f8899..367275b 100644 --- a/tasks/lib/compress.js +++ b/tasks/lib/compress.js @@ -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; } diff --git a/test/compress_test.js b/test/compress_test.js index 24f3dac..3d49bb1 100644 --- a/test/compress_test.js +++ b/test/compress_test.js @@ -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 = [