sindresorhus / gulp-zip

ZIP compress files
MIT License
270 stars 47 forks source link

Skips empty folders #44

Closed rootty closed 9 years ago

rootty commented 9 years ago

Hello,

I have following folder structure:

gulp.task('ziptest', function () {
    return gulp.src('zip_test/**')
        .pipe(ziptest('archive.zip'))
        .pipe(gulp.dest(''));
});

As a result I have archive.zip with all folders except /folder2

Test environment: 1) Windows 8.1 2) "gulp": "^3.8.10" 3) "gulp-zip": "^2.0.3" 4) node -v v0.12.0

rootty commented 9 years ago

Even if i put .gitignore file into folder2/, and folder2/folder3, if folder3 is also empty, it skips them.

sindresorhus commented 9 years ago

gulp.src matches files. If you want a folder put a dotfile in it. You'll also need to pass in the option to gulp.src to enable matching dotfiles.

rootty commented 9 years ago

@sindresorhus interesting, if I just copying from src to dest, it also copying empty folders to new destination.

gulp.task('ziptest', function () {
    return gulp.src('zip_test/**/*')
        .pipe(debug({title: 'unicorn:'}))
        //.pipe(ziptest('archive.zip'))
        .pipe(gulp.dest('zip_test2'));
});

Thank you for an advice with .dot-files.

sindresorhus commented 9 years ago

Actually, yeah, I guess I could use https://stuk.github.io/jszip/documentation/api_jszip/folder_data.html for folders.

dduponchel commented 9 years ago

On file(...), dir : file.isDirectory() will work too :) (see https://stuk.github.io/jszip/documentation/api_jszip/file_data.html)

sindresorhus commented 9 years ago

Done in https://github.com/sindresorhus/gulp-zip/commit/1239836bbae8f0961776406e5f55072ebb51d1c8

Still needs a test. I don't have time to do that right now. So if you want it published, PR welcome for a test ;)