Skip to content

Commit

Permalink
docs: add bunfig spec ref
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Jul 12, 2022
1 parent 6b30a18 commit 790f6eb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- name: Setup Bun Runtime
uses: antongolub/action-setup-bun@v1 # or @v1.x.x
with:
# Optional, default is the latest Bun version
# Optional, if empty the latest bun version will be used
# Examples: 0.0.77, 0.1.2, >=0.1
bun-version: 0.1.2

Expand All @@ -23,6 +23,7 @@

# Override bunfig.toml inners
# Optional. JSON-formatted string as input
# See: https://github.com/oven-sh/bun#bunfigtoml
bun-config: '{"install: {"production": false}}'

# Attach $BUN_INSTALL/install/cache to action/cache
Expand Down
14 changes: 6 additions & 8 deletions src/main/ts/install.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import path from 'path'
import semver from 'semver'
import fs from 'fs/promises'
import { fileURLToPath } from 'url'
import * as core from '@actions/core'
import * as glob from '@actions/glob'
import * as tc from '@actions/tool-cache'
import { HttpClient } from '@actions/http-client'

const __dirname = path.dirname(fileURLToPath(import.meta.url))
const http = new HttpClient('@actions/http-client')

export function getArch() {
Expand Down Expand Up @@ -78,19 +76,19 @@ export async function getBunDist(
core.info(`bun ${_version} ${platform} ${arch} found in tool-cache`)
return path.join(cachedBunPath, file)
}
const auth = token ? `token ${token}` : undefined
const bunUri = getBunUri(repo, version, platform, arch)

core.info(`Downloading bun from ${bunUri}`)
const bunDist = await tc.downloadTool(bunUri, undefined, auth)
const auth = token ? `token ${token}` : undefined
const bunDistUri = getBunDistUri(repo, version, platform, arch)
core.info(`Downloading bun from ${bunDistUri}`)
const bunDist = await tc.downloadTool(bunDistUri, undefined, auth)

await tc.cacheFile(bunDist, file, 'bun', _version, arch)
core.info(`bun dist tool-cached as ${tc.find('bun', _version, arch)}`)
core.info(`bun dist tool-cached: ${tc.find('bun', _version, arch)}`)

return bunDist
}

export function getBunUri(
export function getBunDistUri(
repo: string,
version: string,
platform: string,
Expand Down
6 changes: 3 additions & 3 deletions src/test/ts/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as assert from 'uvu/assert'
import {
install,
pickVersion,
getBunUri,
getBunDistUri,
getPlatform,
getArch,
} from '../../main/ts/install.js'
Expand Down Expand Up @@ -43,9 +43,9 @@ test('pickVersion()', async () => {
}
})

test('getBunUri()', async () => {
test('getBunDistUri()', async () => {
assert.equal(
getBunUri(
getBunDistUri(
'Jarred-Sumner/bun-releases-for-updater',
'bun-v0.1.2',
'darwin',
Expand Down
2 changes: 1 addition & 1 deletion target/main/index.js

Large diffs are not rendered by default.

0 comments on commit 790f6eb

Please sign in to comment.