mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 06:54:13 +08:00
- Update parseAllowedTools to accept both --allowedTools and --allowed-tools - Add regex alternation to support both camelCase and kebab-case variants - Add test cases for unquoted and quoted kebab-case formats - All existing tests continue to pass 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
23 lines
727 B
TypeScript
23 lines
727 B
TypeScript
export function parseAllowedTools(claudeArgs: string): string[] {
|
|
// Match --allowedTools or --allowed-tools followed by the value
|
|
// Handle both quoted and unquoted values
|
|
const patterns = [
|
|
/--(?:allowedTools|allowed-tools)\s+"([^"]+)"/, // Double quoted
|
|
/--(?:allowedTools|allowed-tools)\s+'([^']+)'/, // Single quoted
|
|
/--(?:allowedTools|allowed-tools)\s+([^\s]+)/, // Unquoted
|
|
];
|
|
|
|
for (const pattern of patterns) {
|
|
const match = claudeArgs.match(pattern);
|
|
if (match && match[1]) {
|
|
// Don't return if the value starts with -- (another flag)
|
|
if (match[1].startsWith("--")) {
|
|
return [];
|
|
}
|
|
return match[1].split(",").map((t) => t.trim());
|
|
}
|
|
}
|
|
|
|
return [];
|
|
}
|