Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] use fs.createReadStream instead of fs.readFileSync #252

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion __tests__/github.test.ts
Expand Up @@ -19,7 +19,9 @@ describe("github", () => {
assert.equal(name, "bar.txt");
assert.equal(mime, "text/plain");
assert.equal(size, 10);
assert.equal(data.toString(), "release me");
for await (const value of data) {
assert.equal(value, "release me");
}
});
});
});
6 changes: 3 additions & 3 deletions src/github.ts
@@ -1,7 +1,7 @@
import fetch from "node-fetch";
import { GitHub } from "@actions/github/lib/utils";
import { Config, isTag, releaseBody } from "./util";
import { statSync, readFileSync } from "fs";
import { statSync, createReadStream } from "fs";
import { getType } from "mime";
import { basename } from "path";

Expand All @@ -11,7 +11,7 @@ export interface ReleaseAsset {
name: string;
mime: string;
size: number;
data: Buffer;
data: NodeJS.ReadableStream;
}

export interface Release {
Expand Down Expand Up @@ -128,7 +128,7 @@ export const asset = (path: string): ReleaseAsset => {
name: basename(path),
mime: mimeOrDefault(path),
size: statSync(path).size,
data: readFileSync(path),
data: createReadStream(path),
};
};

Expand Down