Skip to content

R2-3182: Remove wrangler Banner from R2 GetObject in Pipe Mode #9800

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

Merged
merged 2 commits into from
Jul 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/easy-bikes-cut.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

remove banner from r2 getobject in pipe mode
54 changes: 54 additions & 0 deletions packages/wrangler/src/__tests__/r2/pipe.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { writeFileSync } from "node:fs";
import { mockConsoleMethods } from "../helpers/mock-console";
import { runInTempDir } from "../helpers/run-in-tmp";
import { runWrangler } from "../helpers/run-wrangler";

vi.unmock("../../wrangler-banner");
const decoder = new TextDecoder();
describe("pipe test", () => {
const consoleSpy = mockConsoleMethods();
const stdSpy = vi
.spyOn(process.stdout, "write")
.mockImplementation(() => true);
runInTempDir();

it("should display banner", async () => {
writeFileSync("wormhole.txt", "passageway");
await runWrangler(
`r2 object put bucket-object-test/wormhole.txt --file ./wormhole.txt `
);
await runWrangler("r2 object get bucket-object-test/wormhole.txt");

expect(stdSpy).not.toBeCalled();
expect(consoleSpy.out).toMatchInlineSnapshot(`
"
⛅️ wrangler x.x.x
──────────────────
Resource location: local
Use --remote if you want to access the remote instance.
Creating object \\"wormhole.txt\\" in bucket \\"bucket-object-test\\".
Upload complete.
⛅️ wrangler x.x.x
──────────────────
Resource location: local
Use --remote if you want to access the remote instance.
Downloading \\"wormhole.txt\\" from \\"bucket-object-test\\".
Download complete."
`);
});

it("should not display banner in pipe mode", async () => {
writeFileSync("wormhole.txt", "passageway");
await runWrangler(
`r2 object put bucket-object-test/wormhole.txt --file ./wormhole.txt `
);
await runWrangler("r2 object get bucket-object-test/wormhole.txt --pipe");

expect(
decoder.decode(stdSpy.mock.calls[0][0] as unknown as Uint8Array)
).toMatchInlineSnapshot(`"passageway"`);
});
});
3 changes: 3 additions & 0 deletions packages/wrangler/src/r2/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ export const r2ObjectGetCommand = createCommand({
},
},
behaviour: {
printBanner({ pipe }) {
return !pipe;
},
printResourceLocation(args) {
return !args?.pipe;
},
Expand Down
Loading