Skip to content

Commit 24838eb

Browse files
committed
feat(sorting): allow github api to make calls without token
1 parent 31a1161 commit 24838eb

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

scripts/sort_themes.nu

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,20 @@
66

77
# Github API.
88
export def github [
9-
token: string # API Token.
9+
token?: string # API Token.
1010
]: record<owner: string, name: string> -> record<pushed_at: string, stargazers_count: int, avatar: string> {
1111
let repo = $in
1212

13-
let item = http get $"https://api.github.com/repos/($repo.owner)/($repo.name)" --headers {
14-
Authorization: $"Bearer ($token)"
13+
let headers = if ($token | is-empty) {
14+
[]
15+
} else {
16+
{
17+
Authorization: $"Bearer ($token)"
18+
}
1519
}
1620

21+
let item = http get $"https://api.github.com/repos/($repo.owner)/($repo.name)" --headers $headers
22+
1723
{
1824
pushed_at: $item.pushed_at
1925
stargazers_count: ($item.stargazers_count | into int)

0 commit comments

Comments
 (0)