Skip to content

Commit 07a2257

Browse files
authored
fix: fix file closing issue (#629)
* fix: handle file closing gracefully * fix: failing test on Windows * format code using npm run fmt
1 parent d5382d3 commit 07a2257

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/github.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ export const upload = async (
180180
endpoint.searchParams.append("name", name);
181181
const fh = await open(path);
182182
try {
183+
const stream = fh.readableWebStream();
183184
const resp = await github.request({
184185
method: "POST",
185186
url: endpoint.toString(),
@@ -188,7 +189,7 @@ export const upload = async (
188189
"content-type": mime,
189190
authorization: `token ${config.github_token}`,
190191
},
191-
data: fh.readableWebStream(),
192+
data: stream,
192193
});
193194
const json = resp.data;
194195
if (resp.status !== 201) {
@@ -201,7 +202,7 @@ export const upload = async (
201202
console.log(`✅ Uploaded ${name}`);
202203
return json;
203204
} finally {
204-
await fh.close();
205+
await fh.close().catch(() => {});
205206
}
206207
};
207208

src/util.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ const parseMakeLatest = (
9191
export const paths = (patterns: string[]): string[] => {
9292
return patterns.reduce((acc: string[], pattern: string): string[] => {
9393
return acc.concat(
94-
glob.sync(pattern).filter((path) => statSync(path).isFile()),
94+
glob
95+
.sync(pattern)
96+
.filter((path) => statSync(path).isFile())
97+
.map((path) => path.replace(/\\/g, "/")),
9598
);
9699
}, []);
97100
};

0 commit comments

Comments
 (0)