Skip to content

Commit bbb7919

Browse files
committed
Detect bun & deno
1 parent 4be6031 commit bbb7919

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

dist/index/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29659,6 +29659,8 @@ function shouldUseSymlinks() {
2965929659

2966029660
async function detectFrameworks(rootPath = './') {
2966129661
const detectors = [
29662+
detectBun,
29663+
detectDeno,
2966229664
detectGo,
2966329665
detectHomebrew,
2966429666
detectJava,
@@ -29677,6 +29679,20 @@ async function detectFrameworks(rootPath = './') {
2967729679
}
2967829680
return detected;
2967929681
}
29682+
async function detectBun(rootPath) {
29683+
let detected = [];
29684+
if (external_node_fs_namespaceObject.existsSync(external_node_path_namespaceObject.join(rootPath, 'bun.lock'))) {
29685+
detected.push('bun');
29686+
}
29687+
return detected;
29688+
}
29689+
async function detectDeno(rootPath) {
29690+
let detected = [];
29691+
if (external_node_fs_namespaceObject.existsSync(external_node_path_namespaceObject.join(rootPath, 'deno.lock'))) {
29692+
detected.push('deno');
29693+
}
29694+
return detected;
29695+
}
2968029696
async function detectGo(rootPath) {
2968129697
let detected = [];
2968229698
if (external_node_fs_namespaceObject.existsSync(external_node_path_namespaceObject.join(rootPath, 'go.mod'))) {

src/framework.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,24 @@ beforeEach(() => {
88
vol.reset(); // reset the state of in-memory fs
99
});
1010

11+
test('detects bun', async () => {
12+
vol.fromJSON({
13+
'mockdata/bun.lock': '',
14+
});
15+
16+
const detected = await detectFrameworks('mockdata');
17+
expect(detected).toContain('bun');
18+
});
19+
20+
test('detects deno', async () => {
21+
vol.fromJSON({
22+
'mockdata/deno.lock': '',
23+
});
24+
25+
const detected = await detectFrameworks('mockdata');
26+
expect(detected).toContain('deno');
27+
});
28+
1129
test('detects go mod', async () => {
1230
vol.fromJSON({
1331
'mockdata/go.mod': '',

src/framework.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import * as path from "node:path";
33

44
export async function detectFrameworks(rootPath = './'): Promise<string[]> {
55
const detectors: Array<(rootPath: string) => Promise<string[]>> = [
6+
detectBun,
7+
detectDeno,
68
detectGo,
79
detectHomebrew,
810
detectJava,
@@ -24,6 +26,26 @@ export async function detectFrameworks(rootPath = './'): Promise<string[]> {
2426
return detected;
2527
}
2628

29+
async function detectBun(rootPath: string): Promise<string[]> {
30+
let detected: string[] = [];
31+
32+
if (fs.existsSync(path.join(rootPath, 'bun.lock'))) {
33+
detected.push('bun');
34+
}
35+
36+
return detected;
37+
}
38+
39+
async function detectDeno(rootPath: string): Promise<string[]> {
40+
let detected: string[] = [];
41+
42+
if (fs.existsSync(path.join(rootPath, 'deno.lock'))) {
43+
detected.push('deno');
44+
}
45+
46+
return detected;
47+
}
48+
2749
async function detectGo(rootPath: string): Promise<string[]> {
2850
let detected: string[] = [];
2951

0 commit comments

Comments
 (0)