diff --git a/__tests__/unarchive.test.ts b/__tests__/unarchive.test.ts index 73b1da6..b173e5b 100644 --- a/__tests__/unarchive.test.ts +++ b/__tests__/unarchive.test.ts @@ -36,8 +36,10 @@ describe('extract', () => { test('extracts a tar.gz archive into a created destination directory', async () => { const destination = path.join(testRoot, 'tar-gz-output') + const archivePath = path.join(testRoot, 'tar-zip-ball-only-repo.tar.gz') + fs.copyFileSync(fixturePath('tar-zip-ball-only-repo.tar.gz'), archivePath) - await extract(fixturePath('tar-zip-ball-only-repo.tar.gz'), destination) + await extract(archivePath, destination) expect(fs.existsSync(destination)).toBe(true) expect(fs.readdirSync(destination).length).toBeGreaterThan(0) diff --git a/src/unarchive.ts b/src/unarchive.ts index bf7b1d2..a9f9294 100644 --- a/src/unarchive.ts +++ b/src/unarchive.ts @@ -50,6 +50,14 @@ export const extract = async ( await zip.extract(null, destDir) await zip.close() } + + fs.rm(filePath, err => { + if (err) { + core.warning( + `Failed to delete archive ${filename} after extraction: ${err.message}` + ) + } + }) core.info(`Extracted ${filename} to ${destDir}`) } catch (err) { // Provide context for extraction failures