Skip to content

Commit

Permalink
chore: add basic erlang detection via rebar
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstork committed Oct 16, 2024
1 parent c1e49ae commit 4c6705d
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/erlang.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 erlang when rebar.config is present', async ({ fs }) => {
const cwd = mockFileSystem({
'rebar.config': '',
})

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

test('detects erlang when rebar.lock is present', async ({ fs }) => {
const cwd = mockFileSystem({
'rebar.lock': '',
})

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

export class Erlang extends LangRuntime {
id = 'erlang'
name = 'Erlang'
configFiles = ['rebar.config', 'rebar.lock']
}
3 changes: 2 additions & 1 deletion packages/build-info/src/runtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Brew } from './brew.js'
import { Bun } from './bun.js'
import { Emacs } from './cask.js'
import { Dotnet } from './dotnet.js'
import { Erlang } from './erlang.js'
import { Go } from './go.js'
import { Java } from './java.js'
import { Node } from './node.js'
Expand All @@ -11,4 +12,4 @@ import { Ruby } from './ruby.js'
import { Rust } from './rust.js'
import { Swift } from './swift.js'

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

0 comments on commit 4c6705d

Please sign in to comment.