Skip to content

Commit

Permalink
Update getArchiveType method
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolai-laevskii committed Oct 9, 2023
1 parent 5c16ddf commit 508df3d
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions packages/tool-cache/src/archive/get-archive-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,14 @@ export const getArchiveType = async (filePath: string): Promise<ArchiveType> =>
const readStream = readStreamFromDescriptor(fd)

const closeEverythingAndResolve = (result: ArchiveType): void => {
readStream.close(() => {
fs.close(fd, () => resolve(result as '7z' | 'zip' | 'xar' | 'tar'))
})
readStream.close()
fs.close(fd, () => resolve(result as '7z' | 'zip' | 'xar' | 'tar'))
readStream.push(null)
}

const closeEverythingAndReject = (error?: Error): void => {
readStream.close(() => {
fs.close(fd, () =>
reject(
error ?? Error(`Unable to determine archive type of ${filePath}`)
)
)
})
readStream.close()
fs.close(fd, () => reject(error ?? Error('Unable to read file')))
readStream.push(null)
}

Expand Down

0 comments on commit 508df3d

Please sign in to comment.