gulp-decompress
Advanced tools
Comparing version 2.0.3 to 3.0.0
58
index.js
@@ -6,8 +6,8 @@ 'use strict'; | ||
const PluginError = require('plugin-error'); | ||
const Transform = require('readable-stream/transform'); | ||
const {Transform} = require('readable-stream'); | ||
const Vinyl = require('vinyl'); | ||
module.exports = opts => new Transform({ | ||
module.exports = options => new Transform({ | ||
objectMode: true, | ||
transform(file, enc, cb) { | ||
async transform(file, enc, cb) { | ||
if (file.isNull()) { | ||
@@ -28,33 +28,35 @@ cb(null, file); | ||
decompress(file.contents, opts) | ||
.then(files => { | ||
for (const x of files) { | ||
const stat = new fs.Stats(); | ||
try { | ||
const decompressedFiles = await decompress(file.contents, options); | ||
stat.mtime = x.mtime; | ||
if (x.type === 'symlink') { | ||
stat.isSymbolicLink = () => true; | ||
} else { | ||
stat.mode = x.mode; | ||
stat.isDirectory = () => x.type === 'directory'; | ||
} | ||
for (const decompressedFile of decompressedFiles) { | ||
const stats = new fs.Stats(); | ||
const vinylOptions = { | ||
stat, | ||
contents: (stat.isDirectory() || stat.isSymbolicLink()) ? null : x.data, | ||
path: x.path | ||
}; | ||
if (x.linkname) { | ||
vinylOptions.symlink = x.linkname; | ||
} | ||
stats.mtime = decompressedFile.mtime; | ||
this.push(new Vinyl(vinylOptions)); | ||
if (decompressedFile.type === 'symlink') { | ||
stats.isSymbolicLink = () => true; | ||
} else { | ||
stats.mode = decompressedFile.mode; | ||
stats.isDirectory = () => decompressedFile.type === 'directory'; | ||
} | ||
cb(); | ||
}) | ||
.catch(error => { | ||
cb(new PluginError('gulp-decompress:', error, {fileName: file.path})); | ||
}); | ||
const vinylOptions = { | ||
stat: stats, | ||
contents: (stats.isDirectory() || stats.isSymbolicLink()) ? null : decompressedFile.data, | ||
path: decompressedFile.path | ||
}; | ||
if (decompressedFile.linkname) { | ||
vinylOptions.symlink = decompressedFile.linkname; | ||
} | ||
this.push(new Vinyl(vinylOptions)); | ||
} | ||
cb(); | ||
} catch (error) { | ||
cb(new PluginError('gulp-decompress:', error, {fileName: file.path})); | ||
} | ||
} | ||
}); |
{ | ||
"name": "gulp-decompress", | ||
"version": "2.0.3", | ||
"description": "Extract TAR, TAR.BZ2, TAR.GZ and ZIP archives", | ||
"license": "MIT", | ||
"repository": "kevva/gulp-decompress", | ||
"author": { | ||
"name": "Kevin Mårtensson", | ||
"email": "kevinmartensson@gmail.com", | ||
"url": "https://github.com/kevva" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"bz2", | ||
"bzip2", | ||
"decompress", | ||
"extract", | ||
"gulpplugin", | ||
"tar", | ||
"tar.bz", | ||
"tar.gz", | ||
"unzip", | ||
"zip" | ||
], | ||
"dependencies": { | ||
"archive-type": "^4.0.0", | ||
"decompress": "^4.0.0", | ||
"plugin-error": "^1.0.1", | ||
"readable-stream": "^2.0.2", | ||
"vinyl": "^2.1.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"get-stream": "^3.0.0", | ||
"is-jpg": "^1.0.0", | ||
"pify": "^3.0.0", | ||
"xo": "*" | ||
} | ||
"name": "gulp-decompress", | ||
"version": "3.0.0", | ||
"description": "Extract TAR, TAR.BZ2, TAR.GZ and ZIP archives", | ||
"license": "MIT", | ||
"repository": "kevva/gulp-decompress", | ||
"author": { | ||
"name": "Kevin Mårtensson", | ||
"email": "kevinmartensson@gmail.com", | ||
"url": "https://github.com/kevva" | ||
}, | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"bz2", | ||
"bzip2", | ||
"decompress", | ||
"extract", | ||
"gulpplugin", | ||
"tar", | ||
"tar.bz", | ||
"tar.gz", | ||
"unzip", | ||
"zip" | ||
], | ||
"dependencies": { | ||
"archive-type": "^4.0.0", | ||
"decompress": "^4.0.0", | ||
"plugin-error": "^1.0.1", | ||
"readable-stream": "^3.4.0", | ||
"vinyl": "^2.1.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^2.3.0", | ||
"get-stream": "^5.1.0", | ||
"is-jpg": "^2.0.0", | ||
"xo": "^0.24.0" | ||
} | ||
} |
@@ -30,6 +30,1 @@ # gulp-decompress [![Build Status](https://travis-ci.org/kevva/gulp-decompress.svg?branch=master)](https://travis-ci.org/kevva/gulp-decompress) | ||
See the [decompress options](https://github.com/kevva/decompress#options). | ||
## License | ||
MIT © [Kevin Mårtensson](https://github.com/kevva) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4007
4
49
30
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedstring_decoder@1.3.0(transitive)
Updatedreadable-stream@^3.4.0