Skip to content

Commit

Permalink
fix flaky bun-create.test.ts with git templates (#10662)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylan-conway authored Apr 29, 2024
1 parent 72b3045 commit cacf97c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docs/cli/bun-create.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ After cloning a template, `bun create` will automatically remove the `"bun-creat

---

- `GITHUB_ACCESS_TOKEN`
- This lets `bun create` work with private repositories or if you get rate-limited
- `GITHUB_TOKEN` (or `GITHUB_ACCESS_TOKEN`)
- This lets `bun create` work with private repositories or if you get rate-limited. `GITHUB_TOKEN` is chosen over `GITHUB_ACCESS_TOKEN` if both exist.

{% /table %}

Expand Down
2 changes: 1 addition & 1 deletion src/cli.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2206,7 +2206,7 @@ pub const Command = struct {
\\ <b><green>bun create<r> <blue>\<username/repo\><r> <cyan>[...flags]<r> <blue>[dest]<r>
\\
\\<b>Environment variables:<r>
\\ <cyan>GITHUB_ACCESS_TOKEN<r> <d>Supply a token to download code from GitHub with a higher rate limit<r>
\\ <cyan>GITHUB_TOKEN<r> <d>Supply a token to download code from GitHub with a higher rate limit<r>
\\ <cyan>GITHUB_API_DOMAIN<r> <d>Configure custom/enterprise GitHub domain. Default "api.github.com".<r>
\\ <cyan>NPM_CLIENT<r> <d>Absolute path to the npm client executable<r>
;
Expand Down
2 changes: 1 addition & 1 deletion src/cli/create_command.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1851,7 +1851,7 @@ pub const Example = struct {
var header_entries: Headers.Entries = .{};
var headers_buf: string = "";

if (env_loader.map.get("GITHUB_ACCESS_TOKEN")) |access_token| {
if (env_loader.map.get("GITHUB_TOKEN") orelse env_loader.map.get("GITHUB_ACCESS_TOKEN")) |access_token| {
if (access_token.len > 0) {
headers_buf = try std.fmt.allocPrint(ctx.allocator, "AuthorizationBearer {s}", .{access_token});
try header_entries.append(
Expand Down
12 changes: 6 additions & 6 deletions src/cli/upgrade_command.zig
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,19 @@ pub const UpgradeCommand = struct {
),
);

if (env_loader.map.get("GITHUB_ACCESS_TOKEN")) |access_token| {
if (env_loader.map.get("GITHUB_TOKEN") orelse env_loader.map.get("GITHUB_ACCESS_TOKEN")) |access_token| {
if (access_token.len > 0) {
headers_buf = try std.fmt.allocPrint(allocator, default_github_headers ++ "Access-TokenBearer {s}", .{access_token});
headers_buf = try std.fmt.allocPrint(allocator, default_github_headers ++ "AuthorizationBearer {s}", .{access_token});
try header_entries.append(
allocator,
Headers.Kv{
.name = Api.StringPointer{
.offset = accept.value.length + accept.value.offset,
.length = @as(u32, @intCast("Access-Token".len)),
.offset = accept.value.offset + accept.value.length,
.length = @as(u32, @intCast("Authorization".len)),
},
.value = Api.StringPointer{
.offset = @as(u32, @intCast(accept.value.length + accept.value.offset + "Access-Token".len)),
.length = @as(u32, @intCast(access_token.len)),
.offset = @as(u32, @intCast(accept.value.offset + accept.value.length + "Authorization".len)),
.length = @as(u32, @intCast("Bearer ".len + access_token.len)),
},
},
);
Expand Down

0 comments on commit cacf97c

Please sign in to comment.