Fix: Simplify role detection to work with all path formats
- Remove leading slash requirement - use includes() directly - Add word boundary regex for 'api' to avoid false matches - Covers /srv/joylo-api, /srv/joylo-apps/joylo-admin, etc - Should fix 'unknown' role detection issue 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -6,15 +6,15 @@ import { z } from 'zod';
|
||||
function detectRole(): string {
|
||||
const cwd = process.cwd();
|
||||
|
||||
// Check for specific workspace patterns with leading slash
|
||||
if (cwd.includes('/joylo-admin')) return 'admin-dev';
|
||||
if (cwd.includes('/joylo-api')) return 'api-dev';
|
||||
if (cwd.includes('/joylo-web')) return 'web-dev';
|
||||
// Match patterns - check most specific first
|
||||
if (cwd.includes('joylo-admin') || cwd.includes('joylo/admin')) return 'admin-dev';
|
||||
if (cwd.includes('joylo-api') || cwd.includes('joylo/api')) return 'api-dev';
|
||||
if (cwd.includes('joylo-web') || cwd.includes('joylo/web')) return 'web-dev';
|
||||
|
||||
// Fallback for different path formats
|
||||
if (cwd.match(/admin/i)) return 'admin-dev';
|
||||
if (cwd.match(/api/i)) return 'api-dev';
|
||||
if (cwd.match(/web/i)) return 'web-dev';
|
||||
// Fallback regex
|
||||
if (/admin/i.test(cwd)) return 'admin-dev';
|
||||
if (/\bapi\b/i.test(cwd)) return 'api-dev';
|
||||
if (/\bweb\b/i.test(cwd)) return 'web-dev';
|
||||
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user