diff --git a/packages/build-info/src/runtime/bun.test.ts b/packages/build-info/src/runtime/bun.test.ts new file mode 100644 index 0000000000..65e7d4e789 --- /dev/null +++ b/packages/build-info/src/runtime/bun.test.ts @@ -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') +}) diff --git a/packages/build-info/src/runtime/bun.ts b/packages/build-info/src/runtime/bun.ts new file mode 100644 index 0000000000..8b11e6f667 --- /dev/null +++ b/packages/build-info/src/runtime/bun.ts @@ -0,0 +1,7 @@ +import { LangRuntime } from './runtime.js' + +export class Bun extends LangRuntime { + id = 'bun' + name = 'Bun' + configFiles = ['bun.lockb', 'bunfig.toml'] +} diff --git a/packages/build-info/src/runtime/index.ts b/packages/build-info/src/runtime/index.ts index 9e832007c8..080500ba4c 100644 --- a/packages/build-info/src/runtime/index.ts +++ b/packages/build-info/src/runtime/index.ts @@ -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' @@ -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]