fix: revert fs:readableWebStream change (#632)

* Revert "fix: fix file closing issue (#629)"

This reverts commit 07a2257003.

* fix: revert `fh.readableWebStream` change

Signed-off-by: Rui Chen <rui@chenrui.dev>

---------

Signed-off-by: Rui Chen <rui@chenrui.dev>
This commit is contained in:
Rui Chen 2025-06-10 18:27:48 -04:00 committed by GitHub
parent f3cad8bcbf
commit 552dc5524b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 14 additions and 22 deletions

View file

@ -1,9 +1,9 @@
import { GitHub } from "@actions/github/lib/utils";
import { Config, isTag, releaseBody, alignAssetName } from "./util";
import { statSync } from "fs";
import { open } from "fs/promises";
import { lookup } from "mime-types";
import { basename } from "path";
import { alignAssetName, Config, isTag, releaseBody } from "./util";
type GitHub = InstanceType<typeof GitHub>;
@ -180,7 +180,6 @@ export const upload = async (
endpoint.searchParams.append("name", name);
const fh = await open(path);
try {
const stream = fh.readableWebStream();
const resp = await github.request({
method: "POST",
url: endpoint.toString(),
@ -189,7 +188,7 @@ export const upload = async (
"content-type": mime,
authorization: `token ${config.github_token}`,
},
data: stream,
data: fh.readableWebStream({ type: "bytes" }),
});
const json = resp.data;
if (resp.status !== 201) {
@ -202,7 +201,7 @@ export const upload = async (
console.log(`✅ Uploaded ${name}`);
return json;
} finally {
await fh.close().catch(() => {});
await fh.close();
}
};

View file

@ -91,10 +91,7 @@ const parseMakeLatest = (
export const paths = (patterns: string[]): string[] => {
return patterns.reduce((acc: string[], pattern: string): string[] => {
return acc.concat(
glob
.sync(pattern)
.filter((path) => statSync(path).isFile())
.map((path) => path.replace(/\\/g, "/")),
glob.sync(pattern).filter((path) => statSync(path).isFile()),
);
}, []);
};