gulp-zip-plus
v1.0.1
Published
ZIP compress files
Maintainers
Readme
gulp-zip-plus
ZIP compress files from Gulp tasks.
This is a fork of gulp-zip with the addition of the ability to
specify compress and modifiedTime option values on a per-file basis.
Install
npm install --save-dev gulp-zip-plusUsage
import gulp from 'gulp';
import zip from 'gulp-zip-plus';
export default () => (
gulp.src('src/*', { encoding: false })
.pipe(zip('archive.zip'))
.pipe(gulp.dest('dist'))
);API
Supports streaming mode.
zip(filename, options?)
filename
Type: string
options
Type: object
compress
Type: boolean | ((pathname: string) => boolean)
Default: true
Whether to compress files in the archive. If a boolean is passed, applies to all files in the archive. If a function is passed, it is called with the path of each file in the archive, and must return a boolean indicating whether the given file should be compressed.
modifiedTime
Type: Date | ((pathname: string) => Date | null)
Overrides the modification timestamp for some or all files added to the
archive. If a Date is passed, it applies to all files in the archive. If a
function is passed, it is called with the path of each file in the archive,
and must return a Date if it wishes to override the timestamp of that file,
or null if it wishes to use the file's existing modification time.
Tip: Setting it to the same value across executions enables you to create stable archives that change only when the contents of their entries change, regardless of whether those entries were "touched" or regenerated.
buffer
Type: boolean
Default: false
If true, the resulting ZIP file contents will be a buffer. Large zip files may not be possible to buffer, depending on the size of Buffer MAX_LENGTH.
If false, the ZIP file contents will be a stream.
We use this option instead of relying on gulp.src's buffer option because we are mapping many input files to one output file and can't reliably detect what the output mode should be based on the inputs, since Vinyl streams could contain mixed streaming and buffered content.
