Skip to content

Commit a1aaf4d

Browse files
Detect PHP projects by scanning subdirectories too
1 parent 2235751 commit a1aaf4d

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codeep",
3-
"version": "1.2.126",
3+
"version": "1.2.127",
44
"description": "AI-powered coding assistant built for the terminal. Multiple LLM providers, project-aware context, and a seamless development workflow.",
55
"type": "module",
66
"main": "dist/index.js",

src/utils/project.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,20 @@ export function getProjectType(dir: string = process.cwd()): string {
108108
if (existsSync(join(dir, 'mix.exs'))) return 'Elixir';
109109
if (existsSync(join(dir, 'pubspec.yaml'))) return 'Dart/Flutter';
110110
if (existsSync(join(dir, 'CMakeLists.txt'))) return 'C/C++';
111-
// Fallback: detect by file count
111+
// Fallback: detect by scanning root + one level of subdirectories
112112
try {
113-
const files = readdirSync(dir);
114-
const phpFiles = files.filter(f => f.endsWith('.php')).length;
115-
if (phpFiles > 0) return 'PHP';
113+
const entries = readdirSync(dir, { withFileTypes: true });
114+
const phpInRoot = entries.filter(e => e.isFile() && e.name.endsWith('.php')).length;
115+
if (phpInRoot > 0) return 'PHP';
116+
// Check subdirectories
117+
const phpInSubs = entries
118+
.filter(e => e.isDirectory())
119+
.reduce((count, subdir) => {
120+
try {
121+
return count + readdirSync(join(dir, subdir.name)).filter(f => f.endsWith('.php')).length;
122+
} catch { return count; }
123+
}, 0);
124+
if (phpInSubs > 0) return 'PHP';
116125
} catch { /* ignore */ }
117126
return 'Unknown';
118127
}

0 commit comments

Comments
 (0)