Files
release-action/src/Artifact.ts
Nick Cipollo 6c75be85e5
Some checks failed
Test / check_pr (push) Has been cancelled
Fixes #357 Use a read stream for artifacts.
This seems to be safe since octokit mentions ReadableStreams in their fetcher wrapper & tests: https://github.com/octokit/request.js/blob/main/src/fetch-wrapper.ts#L44
(and also it seems to work when I test it).
2023-08-24 08:37:01 -04:00

23 lines
546 B
TypeScript

import { basename } from "path";
import {createReadStream, readFileSync, ReadStream, statSync} from "fs";
export class Artifact {
readonly contentType: string
readonly name: string
readonly path: string
constructor(path: string, contentType: string = "raw") {
this.path = path
this.name = basename(path)
this.contentType = contentType;
}
get contentLength(): number {
return statSync(this.path).size
}
readFile(): ReadStream {
return createReadStream(this.path)
}
}