1
0
Fork 0

use on entry

pull/1666/head
bethanyj28 2024-02-22 17:16:32 -05:00
parent 415c42d27c
commit bc5b3a85ae
2 changed files with 11 additions and 3 deletions

View File

@ -13,7 +13,7 @@ import {
streamExtractExternal streamExtractExternal
} from '../src/internal/download/download-artifact' } from '../src/internal/download/download-artifact'
import {getUserAgentString} from '../src/internal/shared/user-agent' import {getUserAgentString} from '../src/internal/shared/user-agent'
import {noopLogs} from './common' //import {noopLogs} from './common'
import * as config from '../src/internal/shared/config' import * as config from '../src/internal/shared/config'
import {ArtifactServiceClientJSON} from '../src/generated' import {ArtifactServiceClientJSON} from '../src/generated'
import * as util from '../src/internal/shared/util' import * as util from '../src/internal/shared/util'
@ -83,12 +83,13 @@ const createTestArchive = async (): Promise<void> => {
const expectExtractedArchive = async (dir: string): Promise<void> => { const expectExtractedArchive = async (dir: string): Promise<void> => {
for (const file of fixtures.exampleArtifact.files) { for (const file of fixtures.exampleArtifact.files) {
const filePath = path.join(dir, file.path) const filePath = path.join(dir, file.path)
console.log('Checking file:', filePath)
expect(fs.readFileSync(filePath, 'utf8')).toEqual(file.content) expect(fs.readFileSync(filePath, 'utf8')).toEqual(file.content)
} }
} }
const setup = async (): Promise<void> => { const setup = async (): Promise<void> => {
noopLogs() //noopLogs()
await fs.promises.mkdir(testDir, {recursive: true}) await fs.promises.mkdir(testDir, {recursive: true})
await createTestArchive() await createTestArchive()

View File

@ -1,4 +1,6 @@
import fs from 'fs/promises' import fs from 'fs/promises'
import {createWriteStream} from 'fs'
import * as path from 'path'
import * as github from '@actions/github' import * as github from '@actions/github'
import * as core from '@actions/core' import * as core from '@actions/core'
import * as httpClient from '@actions/http-client' import * as httpClient from '@actions/http-client'
@ -89,7 +91,12 @@ export async function streamExtractExternal(
clearTimeout(timer) clearTimeout(timer)
reject(error) reject(error)
}) })
.pipe(unzip.Extract({path: directory})) .pipe(unzip.Parse())
.on('entry', (entry: unzip.Entry) => {
const fullPath = path.normalize(path.join(directory, entry.path))
core.debug(`Extracting artifact entry: ${fullPath}`)
entry.pipe(createWriteStream(fullPath))
})
.on('close', () => { .on('close', () => {
clearTimeout(timer) clearTimeout(timer)
resolve() resolve()