mirror of https://github.com/actions/toolkit
Await finish of filestream so file is created for node16
parent
1d61e5fb19
commit
b9de68a590
|
@ -219,6 +219,14 @@ export class DownloadHttpClient {
|
|||
fileDownloadPath: string
|
||||
): Promise<void> => {
|
||||
destinationStream.close()
|
||||
// await until file is created at downloadpath
|
||||
// wrap destinationStream's open event in promise
|
||||
await new Promise<void>(resolve => {
|
||||
destinationStream.on('close', resolve)
|
||||
if (destinationStream.writableFinished) {
|
||||
resolve()
|
||||
}
|
||||
});
|
||||
await rmFile(fileDownloadPath)
|
||||
destinationStream = fs.createWriteStream(fileDownloadPath)
|
||||
}
|
||||
|
|
|
@ -270,15 +270,6 @@ export async function getFileSize(filePath: string): Promise<number> {
|
|||
}
|
||||
|
||||
export async function rmFile(filePath: string): Promise<void> {
|
||||
// TODO: find actual fix
|
||||
// node 16 `CreateWriteStream` no longer creates a file
|
||||
// download-http-client.ts#L151 no longer creates a file and we fail here
|
||||
try {
|
||||
await fs.stat(filePath)
|
||||
} catch (e) {
|
||||
// File does not exist
|
||||
return
|
||||
}
|
||||
await fs.unlink(filePath)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue