8 changed files with 176 additions and 108 deletions
@ -0,0 +1,49 @@ |
|||||
|
--- a/node_modules/node-gyp/lib/install.js
|
||||
|
+++ b/node_modules/node-gyp/lib/install.js
|
||||
|
@@ -223,21 +223,31 @@
|
||||
|
throw new Error(`${res.status} response downloading ${release.tarballUrl}`) |
||||
|
} |
||||
|
|
||||
|
- await pipeline(
|
||||
|
- res.body,
|
||||
|
- // content checksum
|
||||
|
- new ShaSum((_, checksum) => {
|
||||
|
- const filename = path.basename(release.tarballUrl).trim()
|
||||
|
- contentShasums[filename] = checksum
|
||||
|
- log.verbose('content checksum', filename, checksum)
|
||||
|
- }),
|
||||
|
- tar.extract({
|
||||
|
- strip: 1,
|
||||
|
- cwd: tarExtractDir,
|
||||
|
- filter: isValid,
|
||||
|
- onwarn
|
||||
|
- })
|
||||
|
- )
|
||||
|
+ const shaSum = new ShaSum((_, checksum) => {
|
||||
|
+ const filename = path.basename(release.tarballUrl).trim()
|
||||
|
+ contentShasums[filename] = checksum
|
||||
|
+ log.verbose('content checksum', filename, checksum)
|
||||
|
+ })
|
||||
|
+ const chunks = shaSum[Symbol.asyncIterator]()
|
||||
|
+ const next = () => chunks.next().catch(() => ({ done: true, value: undefined }))
|
||||
|
+ const extract = async () => {
|
||||
|
+ try {
|
||||
|
+ await tar.extract({
|
||||
|
+ strip: 1,
|
||||
|
+ cwd: tarExtractDir,
|
||||
|
+ filter: isValid,
|
||||
|
+ onwarn,
|
||||
|
+ input: { [Symbol.asyncIterator]: () => ({ next }) }
|
||||
|
+ })
|
||||
|
+ } catch (err) {
|
||||
|
+ shaSum.destroy()
|
||||
|
+ throw err
|
||||
|
+ }
|
||||
|
+ while (!(await next()).done) {
|
||||
|
+ continue
|
||||
|
+ }
|
||||
|
+ }
|
||||
|
+ await Promise.all([pipeline(res.body, shaSum), extract()])
|
||||
|
} catch (err) { |
||||
|
// something went wrong downloading the tarball? |
||||
|
if (err.code === 'ENOTFOUND') { |
||||
@ -0,0 +1,105 @@ |
|||||
|
--- a/node_modules/pacote/lib/dir.js
|
||||
|
+++ b/node_modules/pacote/lib/dir.js
|
||||
|
@@ -1,4 +1,5 @@
|
||||
|
const { resolve } = require('node:path') |
||||
|
+const { Readable } = require('node:stream')
|
||||
|
const packlist = require('npm-packlist') |
||||
|
const runScript = require('@npmcli/run-script') |
||||
|
const tar = require('tar') |
||||
|
@@ -78,7 +79,7 @@
|
||||
|
} |
||||
|
return packlist(this.tree, { path: this.resolved, prefix, workspaces }) |
||||
|
}) |
||||
|
- .then(files => tar.c(tarCreateOptions(this.package), files)
|
||||
|
+ .then(async files => Readable.fromWeb(await tar.c(tarCreateOptions(this.package), files))
|
||||
|
.on('error', er => stream.emit('error', er)).pipe(stream)) |
||||
|
.catch(er => stream.emit('error', er)) |
||||
|
return stream |
||||
|
--- a/node_modules/pacote/lib/fetcher.js
|
||||
|
+++ b/node_modules/pacote/lib/fetcher.js
|
||||
|
@@ -380,29 +380,47 @@
|
||||
|
await mkdir(dir, { recursive: true }) |
||||
|
return this.#toFile(dest) |
||||
|
} |
||||
|
-
|
||||
|
- #extract (dest, tarball) {
|
||||
|
- const extractor = tar.x(this.#tarxOptions({ cwd: dest }))
|
||||
|
- const p = new Promise((resolve, reject) => {
|
||||
|
- extractor.on('end', () => {
|
||||
|
- resolve({
|
||||
|
- resolved: this.resolved,
|
||||
|
- integrity: this.integrity && String(this.integrity),
|
||||
|
- from: this.from,
|
||||
|
- })
|
||||
|
- })
|
||||
|
|
||||
|
- extractor.on('error', er => {
|
||||
|
- log.warn('tar', er.message)
|
||||
|
- log.silly('tar', er)
|
||||
|
- reject(er)
|
||||
|
- })
|
||||
|
-
|
||||
|
- tarball.on('error', er => reject(er))
|
||||
|
+ async #extract (dest, tarball) {
|
||||
|
+ let streamError = null
|
||||
|
+ tarball.on('error', er => {
|
||||
|
+ streamError = streamError || er
|
||||
|
}) |
||||
|
-
|
||||
|
- tarball.pipe(extractor)
|
||||
|
- return p
|
||||
|
+ const chunks = tarball[Symbol.asyncIterator]()
|
||||
|
+ const next = async () => {
|
||||
|
+ if (!streamError) {
|
||||
|
+ try {
|
||||
|
+ return await chunks.next()
|
||||
|
+ } catch (er) {
|
||||
|
+ streamError = streamError || er
|
||||
|
+ }
|
||||
|
+ }
|
||||
|
+ return { done: true, value: undefined }
|
||||
|
+ }
|
||||
|
+ try {
|
||||
|
+ await tar.extract({
|
||||
|
+ ...this.#tarxOptions({ cwd: dest }),
|
||||
|
+ input: { [Symbol.asyncIterator]: () => ({ next }) },
|
||||
|
+ })
|
||||
|
+ } catch (er) {
|
||||
|
+ if (streamError) {
|
||||
|
+ throw streamError
|
||||
|
+ }
|
||||
|
+ log.warn('tar', er.message)
|
||||
|
+ log.silly('tar', er)
|
||||
|
+ throw er
|
||||
|
+ }
|
||||
|
+ while (!(await next()).done) {
|
||||
|
+ continue
|
||||
|
+ }
|
||||
|
+ if (streamError) {
|
||||
|
+ throw streamError
|
||||
|
+ }
|
||||
|
+ return {
|
||||
|
+ resolved: this.resolved,
|
||||
|
+ integrity: this.integrity && String(this.integrity),
|
||||
|
+ from: this.from,
|
||||
|
+ }
|
||||
|
} |
||||
|
|
||||
|
// always ensure that entries are at least as permissive as our configured |
||||
|
--- a/node_modules/pacote/lib/util/tar-create-options.js
|
||||
|
+++ b/node_modules/pacote/lib/util/tar-create-options.js
|
||||
|
@@ -16,11 +16,10 @@
|
||||
|
// Note that npm-packlist is already filtering out |
||||
|
// anything that is not a regular file, ignored by |
||||
|
// .npmignore or package.json "files", etc. |
||||
|
- filter: (path, stat) => {
|
||||
|
- if (isPackageBin(manifest, path)) {
|
||||
|
- stat.mode |= 0o111
|
||||
|
+ onWriteEntry: (entry) => {
|
||||
|
+ if (isPackageBin(manifest, entry.path)) {
|
||||
|
+ entry.mode |= 0o111
|
||||
|
} |
||||
|
- return true
|
||||
|
}, |
||||
|
|
||||
|
// Provide a specific date in the 1980s for the benefit of zip, |
||||
Loading…
Reference in new issue