Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add basic erlang detection via rebar #5886

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions packages/build-info/src/runtime/erlang.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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.length).toBe(1)
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.length).toBe(1)
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']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My quick research says a nontrivial fraction of Erlang projects won't be using Rebar. As long as that's ok, this seems fine πŸ€·πŸΌβ€β™‚οΈ.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I meant for this to serve as a starting point for us. I don't personally know of any other markers to check for, but if you happen to know any, let's add them!

}
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]
Loading