Skip to content

Commit

Permalink
feat: detect bun as runtime (#5300)
Browse files Browse the repository at this point in the history
* feat: detect bun as runtime

* chore: export bun as runtime

* chore: fix test message
  • Loading branch information
lukasholzer authored Oct 2, 2023
1 parent 21cafcf commit 6f87850
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
27 changes: 27 additions & 0 deletions packages/build-info/src/runtime/bun.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { beforeEach, expect, test } from 'vitest'

import { mockFileSystem } from '../../tests/mock-file-system.js'
import { NodeFS } from '../node/file-system.js'
import { Project } from '../project.js'

beforeEach((ctx) => {
ctx.fs = new NodeFS()
})

test('detects node when bunfig.toml is present', async ({ fs }) => {
const cwd = mockFileSystem({
'bunfig.toml': '',
})

const detected = await new Project(fs, cwd).detectRuntime()
expect(detected[0].name).toBe('Bun')
})

test('detects node when bun.lockb is present', async ({ fs }) => {
const cwd = mockFileSystem({
'bun.lockb': '',
})

const detected = await new Project(fs, cwd).detectRuntime()
expect(detected[0].name).toBe('Bun')
})
7 changes: 7 additions & 0 deletions packages/build-info/src/runtime/bun.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { LangRuntime } from './runtime.js'

export class Bun extends LangRuntime {
id = 'bun'
name = 'Bun'
configFiles = ['bun.lockb', 'bunfig.toml']
}
3 changes: 2 additions & 1 deletion packages/build-info/src/runtime/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Brew } from './brew.js'
import { Bun } from './bun.js'
import { Emacs } from './cask.js'
import { Go } from './go.js'
import { Java } from './java.js'
Expand All @@ -9,4 +10,4 @@ import { Ruby } from './ruby.js'
import { Rust } from './rust.js'
import { Swift } from './swift.js'

export const runtimes = [Node, Ruby, Brew, Emacs, Go, Java, Php, Rust, Swift, Python]
export const runtimes = [Node, Ruby, Brew, Bun, Emacs, Go, Java, Php, Rust, Swift, Python]

0 comments on commit 6f87850

Please sign in to comment.