UNPKG

1.51 kBMarkdownView Raw
1# gulp-zip
2
3> ZIP compress files
4
5## Install
6
7```sh
8npm install --save-dev gulp-zip
9```
10
11## Usage
12
13```js
14import gulp from 'gulp';
15import zip from 'gulp-zip';
16
17export default () => (
18 gulp.src('src/*')
19 .pipe(zip('archive.zip'))
20 .pipe(gulp.dest('dist'))
21);
22```
23
24## API
25
26Supports [streaming mode](https://github.com/gulpjs/gulp/blob/master/docs/API.md#optionsbuffer).
27
28### zip(filename, options?)
29
30#### filename
31
32Type: `string`
33
34#### options
35
36Type: `object`
37
38##### compress
39
40Type: `boolean`\
41Default: `true`
42
43##### modifiedTime
44
45Type: `Date`\
46Default: `undefined`
47
48Overrides the modification timestamp for all files added to the archive.
49
50Tip: 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.
51
52##### buffer
53
54Type: `boolean`\
55Default: `true`
56
57If `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](https://nodejs.org/api/buffer.html#buffer_buffer_constants_max_length).
58
59If `false`, the ZIP file contents will be a stream.
60
61We use this option instead of relying on [gulp.src's `buffer` option](https://gulpjs.com/docs/en/api/src/#options) 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.