Comparing version
33
index.js
@@ -9,3 +9,3 @@ 'use strict'; | ||
module.exports = (filename, opts) => { | ||
module.exports = (filename, options) => { | ||
if (!filename) { | ||
@@ -15,5 +15,6 @@ throw new PluginError('gulp-zip', '`filename` required'); | ||
opts = Object.assign({ | ||
compress: true | ||
}, opts); | ||
options = { | ||
compress: true, | ||
...options | ||
}; | ||
@@ -23,3 +24,3 @@ let firstFile; | ||
return through.obj((file, enc, cb) => { | ||
return through.obj((file, encoding, callback) => { | ||
if (!firstFile) { | ||
@@ -33,3 +34,3 @@ firstFile = file; | ||
if (!pathname) { | ||
cb(); | ||
callback(); | ||
return; | ||
@@ -40,3 +41,3 @@ } | ||
zip.addEmptyDirectory(pathname, { | ||
mtime: opts.modifiedTime || file.stat.mtime || new Date(), | ||
mtime: options.modifiedTime || file.stat.mtime || new Date(), | ||
mode: file.stat.mode | ||
@@ -46,4 +47,4 @@ }); | ||
const stat = { | ||
compress: opts.compress, | ||
mtime: opts.modifiedTime || (file.stat ? file.stat.mtime : new Date()), | ||
compress: options.compress, | ||
mtime: options.modifiedTime || (file.stat ? file.stat.mtime : new Date()), | ||
mode: file.stat ? file.stat.mode : null | ||
@@ -61,10 +62,12 @@ }; | ||
cb(); | ||
}, function (cb) { | ||
callback(); | ||
}, function (callback) { | ||
if (!firstFile) { | ||
cb(); | ||
callback(); | ||
return; | ||
} | ||
getStream.buffer(zip.outputStream).then(data => { | ||
(async () => { | ||
const data = await getStream.buffer(zip.outputStream); | ||
this.push(new Vinyl({ | ||
@@ -77,4 +80,4 @@ cwd: firstFile.cwd, | ||
cb(); | ||
}); | ||
callback(); | ||
})(); | ||
@@ -81,0 +84,0 @@ zip.end(); |
{ | ||
"name": "gulp-zip", | ||
"version": "4.2.0", | ||
"description": "ZIP compress files", | ||
"license": "MIT", | ||
"repository": "sindresorhus/gulp-zip", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"gulpplugin", | ||
"zip", | ||
"archive", | ||
"archiver", | ||
"compress", | ||
"compression", | ||
"file" | ||
], | ||
"dependencies": { | ||
"get-stream": "^3.0.0", | ||
"plugin-error": "^0.1.2", | ||
"through2": "^2.0.1", | ||
"vinyl": "^2.1.0", | ||
"yazl": "^2.1.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"decompress-unzip": "^3.0.0", | ||
"gulp": "^3.9.1", | ||
"vinyl-assign": "^1.2.1", | ||
"vinyl-file": "^3.0.0", | ||
"xo": "*" | ||
} | ||
"name": "gulp-zip", | ||
"version": "5.0.0", | ||
"description": "ZIP compress files", | ||
"license": "MIT", | ||
"repository": "sindresorhus/gulp-zip", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"gulpplugin", | ||
"zip", | ||
"archive", | ||
"archiver", | ||
"compress", | ||
"compression", | ||
"file" | ||
], | ||
"dependencies": { | ||
"get-stream": "^5.1.0", | ||
"plugin-error": "^1.0.1", | ||
"through2": "^3.0.1", | ||
"vinyl": "^2.1.0", | ||
"yazl": "^2.5.1" | ||
}, | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"decompress-unzip": "^3.0.0", | ||
"gulp": "^4.0.2", | ||
"vinyl-assign": "^1.2.1", | ||
"vinyl-file": "^3.0.0", | ||
"xo": "^0.24.0" | ||
}, | ||
"peerDependencies": { | ||
"gulp": ">=4" | ||
} | ||
} |
@@ -31,3 +31,3 @@ # gulp-zip [](https://travis-ci.org/sindresorhus/gulp-zip) | ||
### zip(filename, [options]) | ||
### zip(filename, options?) | ||
@@ -40,3 +40,3 @@ #### filename | ||
Type: `Object` | ||
Type: `object` | ||
@@ -55,7 +55,2 @@ ##### compress | ||
Tip: Setting it to the same value across executions enables you to create stable archives—archives that change only when the contents of their entries change, regardless of whether those entries were "touched" or regenerated. | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) | ||
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. |
64
3.23%4561
-0.28%6
20%54
-8.47%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated