Skip to content

Commit

Permalink
Merge pull request #1602 from actions/robherley/replace-unzip-lib
Browse files Browse the repository at this point in the history
[artifact] replace unzipper with unzip-stream
  • Loading branch information
robherley authored Dec 11, 2023
2 parents 950e171 + 09249a7 commit 37a66eb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 142 deletions.
2 changes: 2 additions & 0 deletions packages/artifact/__tests__/download-artifact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const mockGetArtifactSuccess = jest.fn(() => {
const message = new http.IncomingMessage(new net.Socket())
message.statusCode = 200
message.push(fs.readFileSync(fixtures.exampleArtifact.path))
message.push(null)
return {
message
}
Expand All @@ -113,6 +114,7 @@ const mockGetArtifactFailure = jest.fn(() => {
const message = new http.IncomingMessage(new net.Socket())
message.statusCode = 500
message.push('Internal Server Error')
message.push(null)
return {
message
}
Expand Down
151 changes: 13 additions & 138 deletions packages/artifact/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/artifact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@
"@octokit/plugin-retry": "^3.0.9",
"@octokit/request-error": "^5.0.0",
"@protobuf-ts/plugin": "^2.2.3-alpha.1",
"@types/unzipper": "^0.10.6",
"archiver": "^5.3.1",
"crypto": "^1.0.1",
"jwt-decode": "^3.1.2",
"twirp-ts": "^2.5.0",
"unzipper": "^0.10.14"
"unzip-stream": "^0.3.1"
},
"devDependencies": {
"@types/archiver": "^5.3.2",
"@types/unzip-stream": "^0.3.4",
"typedoc": "^0.25.4",
"typedoc-plugin-markdown": "^3.17.1",
"typescript": "^5.2.2"
Expand Down
9 changes: 7 additions & 2 deletions packages/artifact/src/internal/download/download-artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'fs/promises'
import * as github from '@actions/github'
import * as core from '@actions/core'
import * as httpClient from '@actions/http-client'
import unzipper from 'unzipper'
import unzip from 'unzip-stream'
import {
DownloadArtifactOptions,
DownloadArtifactResponse
Expand Down Expand Up @@ -47,7 +47,12 @@ async function streamExtract(url: string, directory: string): Promise<void> {
)
}

return response.message.pipe(unzipper.Extract({path: directory})).promise()
return new Promise((resolve, reject) => {
response.message
.pipe(unzip.Extract({path: directory}))
.on('close', resolve)
.on('error', reject)
})
}

export async function downloadArtifactPublic(
Expand Down

0 comments on commit 37a66eb

Please sign in to comment.