From bc5b3a85ae98c7ef52f354703f87e9b94c85ea61 Mon Sep 17 00:00:00 2001 From: bethanyj28 Date: Thu, 22 Feb 2024 17:16:32 -0500 Subject: [PATCH] use on entry --- packages/artifact/__tests__/download-artifact.test.ts | 5 +++-- .../artifact/src/internal/download/download-artifact.ts | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/artifact/__tests__/download-artifact.test.ts b/packages/artifact/__tests__/download-artifact.test.ts index 1c0c9b0d..7d8fead5 100644 --- a/packages/artifact/__tests__/download-artifact.test.ts +++ b/packages/artifact/__tests__/download-artifact.test.ts @@ -13,7 +13,7 @@ import { streamExtractExternal } from '../src/internal/download/download-artifact' 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 {ArtifactServiceClientJSON} from '../src/generated' import * as util from '../src/internal/shared/util' @@ -83,12 +83,13 @@ const createTestArchive = async (): Promise => { const expectExtractedArchive = async (dir: string): Promise => { for (const file of fixtures.exampleArtifact.files) { const filePath = path.join(dir, file.path) + console.log('Checking file:', filePath) expect(fs.readFileSync(filePath, 'utf8')).toEqual(file.content) } } const setup = async (): Promise => { - noopLogs() + //noopLogs() await fs.promises.mkdir(testDir, {recursive: true}) await createTestArchive() diff --git a/packages/artifact/src/internal/download/download-artifact.ts b/packages/artifact/src/internal/download/download-artifact.ts index dc54f6fe..995dbafb 100644 --- a/packages/artifact/src/internal/download/download-artifact.ts +++ b/packages/artifact/src/internal/download/download-artifact.ts @@ -1,4 +1,6 @@ import fs from 'fs/promises' +import {createWriteStream} from 'fs' +import * as path from 'path' import * as github from '@actions/github' import * as core from '@actions/core' import * as httpClient from '@actions/http-client' @@ -89,7 +91,12 @@ export async function streamExtractExternal( clearTimeout(timer) 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', () => { clearTimeout(timer) resolve()