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

fix: runtime detection for dotnet #5858

Merged
merged 2 commits into from
Oct 1, 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
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']
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some setups also use Startup.cs as well, but it's not required any longer

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