Closed kierans closed 11 years ago
Ah, that makes sense. I never accounted for that case. I will patch it in a second.
Added, tested, and published. If you upgrade to 0.7
, your dot
option will now hold.
I'm not sure it's fixed and I did check that I've got 0.7:
$ grunt -v zip
Running "zip:app" (zip) task
Verifying property zip.app exists in config...OK
Files: .travis.yml, Gruntfile.js, LICENSE, README.md, UPGRADE-2.2.md, UPGRADE.md, app, bin, composer.json, composer.lock, package.json, src, vendor, web -> archive.zip
File "archive.zip" created.
$ unzip -t archive.zip
Archive: archive.zip
testing: app/ OK
testing: bin/ OK
testing: src/ OK
testing: vendor/ OK
testing: web/ OK
testing: Gruntfile.js OK
testing: LICENSE OK
testing: README.md OK
testing: UPGRADE-2.2.md OK
testing: UPGRADE.md OK
testing: composer.json OK
testing: composer.lock OK
testing: package.json OK
No errors detected in compressed data of archive.zip.
When I unzip the archive there's no .travis.yml
on the filesystem.
Directory contents is also missing:
$ grunt -v zip
Running "zip:app" (zip) task
Verifying property zip.app exists in config...OK
Files: tmp/15927fc52919e9223adc7ed99e125d4d.jpeg -> archive.zip
File "archive.zip" created.
$ unzip -t archive.zip
Archive: archive.zip
testing: tmp/ OK
No errors detected in compressed data of archive.zip.
When I unzip the archive, the tmp
dir is empty, and doesn't contain the JPEG file.
I think it is a problem with your config now rather than the grunt-zip
. grunt uses glob/minimatch for its src
and dest
.
Try out the following config:
files: [
{
src: [ '**/*', "!app/cache/**/*", '!app/logs/**/*' ],
dest: 'archive.zip',
dot: true
}
]
If that doesn't work, you might need to explicitly include the .travis.yml
.
files: [
{
src: [ '**/*', '.travis.yml', "!app/cache/**/*", '!app/logs/**/*' ],
dest: 'archive.zip',
dot: true
}
]
If you want a deeper explanation of globstar
, please see my comments on this issue.
As proof that things are working, if you run the tests for 0.7
, then navigate to test/actual/dot_zip
and unzip -t file.zip
, you will see the output of:
$ unzip -t file.zip
Archive: file.zip
testing: test_files/ OK
testing: test_files/dot/ OK
testing: test_files/dot/.test/ OK
testing: test_files/dot/.test/hello.js OK
testing: test_files/dot/test/ OK
testing: test_files/dot/test/.examplerc OK
No errors detected in compressed data of file.zip.
Lastly, I don't know how/where you are getting the output of:
Verifying property zip.app exists in config...OK
Files: .travis.yml, Gruntfile.js, LICENSE, README.md, UPGRADE-2.2.md, UPGRADE.md, app, bin, composer.json, composer.lock, package.json, src, vendor, web -> archive.zip
Verifying property zip.app exists in config...OK
Files: tmp/15927fc52919e9223adc7ed99e125d4d.jpeg -> archive.zip
The output from my previous comments are from the verbose output of grunt; I've updated my comments above with the correct commands.
I've had a look and the test cases are passing correctly. I added in some extra tests for globbing (grunt.js):
dotglob: {
src: ['test_files/dot/**'],
dest: 'actual/dot_zip/glob.zip',
dot: true
}
'test-zip-dot-glob': {
src: 'actual/dot_zip/glob.zip',
dest: 'actual/dot_zip/glob/unzip'
}
Those tests pass:
$ ls actual/dot_zip/glob/unzip/ -Ra
actual/dot_zip/glob/unzip/:
. .. test_files
actual/dot_zip/glob/unzip/test_files:
. .. dot
actual/dot_zip/glob/unzip/test_files/dot:
. .. test .test
actual/dot_zip/glob/unzip/test_files/dot/test:
. .. .examplerc
actual/dot_zip/glob/unzip/test_files/dot/.test:
. .. hello.js
$ unzip -t actual/dot_zip/glob.zip
Archive: actual/dot_zip/glob.zip
testing: test_files/ OK
testing: test_files/dot/ OK
testing: test_files/dot/.test/ OK
testing: test_files/dot/test/ OK
testing: test_files/dot/.test/hello.js OK
testing: test_files/dot/test/.examplerc OK
No errors detected in compressed data of actual/dot_zip/glob.zip.
However my config (using some of your suggestions) doesn't include the dot files.
zip: {
app: {
files: [
{
src: [ '**', "!app/cache/**/*", '!app/logs/**/*' ],
dest: 'archive.zip',
dot: true
}
]
}
}
Or src: [ '**/*', "!app/cache/**/*", '!app/logs/**/*' ]
I'm not sure what I'm doing wrong here.
Ooooh, right. You are using the new grunt@0.4
syntax. dot
is a property of this.data
try moving it to options
. i.e.
zip: {
app: {
files: [
{
src: [ '**/*', "!app/cache/**/*", '!app/logs/**/*' ],
dest: 'archive.zip'
}
],
options: {
dot: true
}
}
}
grunt
supports many layouts -- I personally prefer the compact
and single object
ones. The files/options
one is new and allows for much better batch support.
Placing the dot property into the options object didn't work, however using the Compact format worked ie:
zip: {
app: {
src: [ '**/*', "!app/cache/**/*", '!app/logs/**/*' ],
dest: 'supportme-<%= pkg.version %>.zip',
dot: true
}
},
Interesting... I call that the single object
format actually. Compact
would look like:
zip: {
'supportme-<%= pkg.version %>.zip': [ '**/*', "!app/cache/**/*", '!app/logs/**/*' ]
}
but it doesn't support any options. I am glad to hear everything is working now =)
If
$ grunt filestest
is run, then any dotfiles (eg:.travis.yml
) is listed in the output. However the dotfile is not included in the zip file when$ grunt zip
is run.