Skip to content

Commit 493e84e

Browse files
committed
fix: pipeToPath should truncate the file
1 parent 9c6769c commit 493e84e

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/request.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ Deno.test("$.request", (t) => {
168168
const originDir = Deno.cwd();
169169
try {
170170
{
171+
// ensure that a truncate happens
172+
$.path(testFilePath).writeTextSync("text".repeat(1002));
171173
const downloadedFilePath = await new RequestBuilder()
172174
.url(new URL("/text-file", serverUrl))
173175
.showProgress()

src/request.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ export class RequestResponse {
626626
const file = await filePath.open({
627627
write: true,
628628
create: true,
629+
truncate: true,
629630
...(options ?? {}),
630631
});
631632
try {

0 commit comments

Comments
 (0)