mirror of https://github.com/actions/toolkit
Update getArchiveType method
parent
5c16ddf520
commit
508df3dce8
|
@ -70,20 +70,14 @@ export const getArchiveType = async (filePath: string): Promise<ArchiveType> =>
|
||||||
const readStream = readStreamFromDescriptor(fd)
|
const readStream = readStreamFromDescriptor(fd)
|
||||||
|
|
||||||
const closeEverythingAndResolve = (result: ArchiveType): void => {
|
const closeEverythingAndResolve = (result: ArchiveType): void => {
|
||||||
readStream.close(() => {
|
readStream.close()
|
||||||
fs.close(fd, () => resolve(result as '7z' | 'zip' | 'xar' | 'tar'))
|
fs.close(fd, () => resolve(result as '7z' | 'zip' | 'xar' | 'tar'))
|
||||||
})
|
|
||||||
readStream.push(null)
|
readStream.push(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
const closeEverythingAndReject = (error?: Error): void => {
|
const closeEverythingAndReject = (error?: Error): void => {
|
||||||
readStream.close(() => {
|
readStream.close()
|
||||||
fs.close(fd, () =>
|
fs.close(fd, () => reject(error ?? Error('Unable to read file')))
|
||||||
reject(
|
|
||||||
error ?? Error(`Unable to determine archive type of ${filePath}`)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
})
|
|
||||||
readStream.push(null)
|
readStream.push(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue