Skip to content

Commit

Permalink
fix: add some support for dotnet runtime detection (#5858)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstork authored Oct 1, 2024
1 parent 2002b42 commit 75eb6a2
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/dotnet.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 dotnet when Program.cs is present', async ({ fs }) => {
const cwd = mockFileSystem({
'Program.cs': '',
})

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

test('detects dotnet when appsettings.json is present', async ({ fs }) => {
const cwd = mockFileSystem({
'appsettings.json': '',
})

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

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

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

0 comments on commit 75eb6a2

Please sign in to comment.