unpack-stream
Advanced tools
Comparing version 2.1.1 to 2.2.0
@@ -9,2 +9,3 @@ /// <reference types="node" /> | ||
generateIntegrity?: boolean; | ||
ignore?: (filename: string) => Boolean; | ||
}; | ||
@@ -31,2 +32,3 @@ export declare function remote(stream: IncomingMessage, dest: string, opts: UnpackRemoteStreamOptions): Promise<{}>; | ||
generateIntegrity?: boolean; | ||
ignore?: (filename: string) => Boolean; | ||
}): Promise<{}>; |
@@ -25,5 +25,6 @@ "use strict"; | ||
} | ||
local(stream | ||
const streamToUnpack = stream | ||
.on('data', (_) => { actualShasum.update(_); }) | ||
.on('error', reject), dest).then(finish).catch(reject); | ||
.on('error', reject); | ||
local(streamToUnpack, dest, opts).then(finish).catch(reject); | ||
// without pausing, gunzip/tar-fs would miss the beginning of the stream | ||
@@ -45,2 +46,3 @@ if (stream.resume) | ||
opts = opts || {}; | ||
const ignore = opts.ignore && function (filename, header) { return opts.ignore(header.name); } || function () { return false; }; | ||
const generateIntegrity = opts.generateIntegrity !== false; | ||
@@ -56,2 +58,3 @@ const index = {}; | ||
strip: 1, | ||
ignore, | ||
mapStream(fileStream, header) { | ||
@@ -63,3 +66,2 @@ headers[header.name] = header; | ||
index[header.name] = { | ||
integrity: sri.toString(), | ||
type: header['type'], | ||
@@ -69,2 +71,5 @@ size: header['size'], | ||
}; | ||
if (sri) { | ||
index[header.name].integrity = sri.toString(); | ||
} | ||
})); | ||
@@ -71,0 +76,0 @@ } |
{ | ||
"name": "unpack-stream", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"description": "Unpack a tarball stream", | ||
@@ -12,6 +12,6 @@ "main": "dist/index.js", | ||
"pretest": "rimraf test/dest", | ||
"test": "npm run tsc && ts-node test", | ||
"md": "mos README.md", | ||
"test": "npm run tsc && preview && ts-node test", | ||
"md": "preview && mos README.md", | ||
"tsc": "rimraf dist && tsc", | ||
"prepublish": "npm run tsc" | ||
"prepublishOnly": "npm run tsc" | ||
}, | ||
@@ -29,4 +29,4 @@ "repository": { | ||
"name": "Zoltan Kochan", | ||
"email": "zoltan.kochan@gmail.com", | ||
"url": "http://kochan.io" | ||
"email": "z@kochan.io", | ||
"url": "https://www.kochan.io" | ||
}, | ||
@@ -41,3 +41,3 @@ "license": "MIT", | ||
"decompress-maybe": "^1.0.0", | ||
"ssri": "^4.1.6", | ||
"ssri": "^5.0.0", | ||
"tar-fs": "^1.14.0" | ||
@@ -47,5 +47,7 @@ }, | ||
"@types/tape": "^4.2.30", | ||
"got": "^7.0.0", | ||
"got": "^8.0.0", | ||
"ignorable": "^1.0.1", | ||
"mos": "^2.0.0-alpha.3", | ||
"mos-plugin-readme": "^1.0.4", | ||
"package-preview": "^1.0.0", | ||
"rimraf": "^2.6.1", | ||
@@ -52,0 +54,0 @@ "tape": "^4.7.0", |
@@ -27,3 +27,3 @@ # unpack-stream | ||
.then(index => console.log(index)) | ||
//> { 'package.json': | ||
//> { 'package.json': | ||
// { integrity: 'sha512-RA0APKvtxz85WYCFX3M/TkVeJZZBcylEwh+GrV7uO/NNJO4G3rzgTrpsypp9AU2hM2QBk9SxCHi1Gb9aaWzpYg==', | ||
@@ -33,3 +33,3 @@ // type: 'file', | ||
// mtime: '2016-01-11T15:24:07.000Z' }, | ||
// 'index.js': | ||
// 'index.js': | ||
// { integrity: 'sha512-3dL1OHn8VWhVDT37f3ZBdou4NrYq2ll//W1lWqx7+4tKBW/WqUx3mDcGyqrBfBeWTIPCd+RiUdF7hp3MQYB9+g==', | ||
@@ -39,3 +39,3 @@ // type: 'file', | ||
// mtime: '2016-01-11T15:17:59.000Z' }, | ||
// license: | ||
// license: | ||
// { integrity: 'sha512-lSw93JVg7wfwyVXKrg6yIFjF9Bidgr+tA/l6XNlrRhjnE6NhwkyPL3xNL47OZScS8qoQkYUwE6slmo7jGesH0Q==', | ||
@@ -45,3 +45,3 @@ // type: 'file', | ||
// mtime: '2016-01-11T15:17:38.000Z' }, | ||
// 'readme.md': | ||
// 'readme.md': | ||
// { integrity: 'sha512-fM882axp7XaC6nzj5XYuzB0KhYpYwwsR3RjyiqOcIrI6C0b9KxrEEug9VpKTfbSbqTOmZ2KEqZLPKrMXFW1Y+g==', | ||
@@ -68,2 +68,3 @@ // type: 'file', | ||
- `[opts.generateIntegrity]` - _Boolean_ - `true` by default. If `true`, generates [Subresource Integrity](https://w3c.github.io/webappsec-subresource-integrity/) for each unpacked file | ||
- `[opts.ignore]` - `(filename: string) => boolean` - a function that decides whether a file should be unpacked from the tarball. | ||
@@ -77,2 +78,3 @@ ### `local(stream, destination, [opts]): Promise<Index>` | ||
- `[opts.generateIntegrity]` - _Boolean_ - `true` by default. If `true`, generates [Subresource Integrity](https://w3c.github.io/webappsec-subresource-integrity/) for each unpacked file | ||
- `[opts.ignore]` - `(filename: string) => boolean` - a function that decides whether a file should be unpacked from the tarball. | ||
@@ -79,0 +81,0 @@ ## License |
Sorry, the diff of this file is not supported yet
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
13177
120
78
10
+ Addedssri@5.3.0(transitive)
- Removedssri@4.1.6(transitive)
Updatedssri@^5.0.0