fix flaky bun-create.test.ts with git templates (#10662)

This commit is contained in:
Dylan Conway
2024-04-29 16:59:07 -07:00
committed by GitHub
parent 72b3045758
commit cacf97ca0a
4 changed files with 10 additions and 10 deletions

View File

@@ -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 %}

View File

@@ -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>
;

View File

@@ -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(

View File

@@ -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)),
},
},
);