Skip to content

Commit 75eb6a2

Browse files
authored
fix: add some support for dotnet runtime detection (#5858)
1 parent 2002b42 commit 75eb6a2

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { beforeEach, expect, test } from 'vitest'
2+
3+
import { mockFileSystem } from '../../tests/mock-file-system.js'
4+
import { NodeFS } from '../node/file-system.js'
5+
import { Project } from '../project.js'
6+
7+
beforeEach((ctx) => {
8+
ctx.fs = new NodeFS()
9+
})
10+
11+
test('detects dotnet when Program.cs is present', async ({ fs }) => {
12+
const cwd = mockFileSystem({
13+
'Program.cs': '',
14+
})
15+
16+
const detected = await new Project(fs, cwd).detectRuntime()
17+
expect(detected[0].name).toBe('Dotnet')
18+
})
19+
20+
test('detects dotnet when appsettings.json is present', async ({ fs }) => {
21+
const cwd = mockFileSystem({
22+
'appsettings.json': '',
23+
})
24+
25+
const detected = await new Project(fs, cwd).detectRuntime()
26+
expect(detected[0].name).toBe('Dotnet')
27+
})
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { LangRuntime } from './runtime.js'
2+
3+
export class Dotnet extends LangRuntime {
4+
id = 'dotnet'
5+
name = 'Dotnet'
6+
configFiles = ['Program.cs', 'appsettings.json']
7+
}

packages/build-info/src/runtime/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Brew } from './brew.js'
22
import { Bun } from './bun.js'
33
import { Emacs } from './cask.js'
4+
import { Dotnet } from './dotnet.js'
45
import { Go } from './go.js'
56
import { Java } from './java.js'
67
import { Node } from './node.js'
@@ -10,4 +11,4 @@ import { Ruby } from './ruby.js'
1011
import { Rust } from './rust.js'
1112
import { Swift } from './swift.js'
1213

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

0 commit comments

Comments
 (0)