-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade Node.js from v16.18.1 to v18.13.0 #144012
Changes from 14 commits
04c3298
d9ccb6c
0beb3ac
283887d
b5aeb71
64341f5
afd74bd
ec9a884
0fbfdc4
292f64e
d131aad
e3a175c
75c2a73
ca2a1c3
ec5b5b4
5f9df2b
93bb7a4
5e98895
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16.18.1 | ||
18.13.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16.18.1 | ||
18.13.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
* 2.0. | ||
*/ | ||
|
||
import { finished } from 'stream/promises'; | ||
|
||
import tar from 'tar'; | ||
import yauzl from 'yauzl'; | ||
|
||
|
@@ -16,19 +18,20 @@ export async function untarBuffer( | |
buffer: Buffer, | ||
filter = (entry: ArchiveEntry): boolean => true, | ||
onEntry = (entry: ArchiveEntry): void => {} | ||
): Promise<unknown> { | ||
) { | ||
const deflatedStream = bufferToStream(buffer); | ||
// use tar.list vs .extract to avoid writing to disk | ||
const inflateStream = tar.list().on('entry', (entry: tar.FileStat) => { | ||
const path = entry.header.path || ''; | ||
const inflateStream = tar.list().on('entry', (entry) => { | ||
const path = entry.path || ''; | ||
if (!filter({ path })) return; | ||
streamToBuffer(entry).then((entryBuffer) => onEntry({ buffer: entryBuffer, path })); | ||
streamToBuffer(entry as unknown as NodeJS.ReadableStream).then((entryBuffer) => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
onEntry({ buffer: entryBuffer, path }) | ||
); | ||
}); | ||
|
||
return new Promise((resolve, reject) => { | ||
inflateStream.on('end', resolve).on('error', reject); | ||
deflatedStream.pipe(inflateStream); | ||
}); | ||
deflatedStream.pipe(inflateStream); | ||
|
||
await finished(inflateStream); | ||
Comment on lines
-28
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the types |
||
} | ||
|
||
export async function unzipBuffer( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accessing the
path
via theheader
works but isn't supported according to the types. Instead it seems that you're supposed to access it directly via the rootpath
property where it's copied to in the constructor:https://github.com/npm/node-tar/blob/26a496e5fa74eeaa0c3539511560fc181ef56557/lib/read-entry.js#L50