UNPKG

route-claudecode

Version:

Advanced routing and transformation system for Claude Code outputs to multiple AI providers

44 lines 1.72 kB
"use strict"; /** * Path resolution utilities */ Object.defineProperty(exports, "__esModule", { value: true }); exports.resolvePath = resolvePath; const path_1 = require("path"); const os_1 = require("os"); const fs_1 = require("fs"); /** * Resolve path with tilde expansion and project config directory search * Handles both regular paths and paths starting with ~/ * Also searches in project config directories if file not found at specified path */ function resolvePath(filePath) { // Handle tilde expansion first let resolvedPath = filePath; if (filePath.startsWith('~/')) { resolvedPath = (0, path_1.resolve)((0, os_1.homedir)(), filePath.slice(2)); } else { resolvedPath = (0, path_1.resolve)(filePath); } // If file exists at the resolved path, return it if ((0, fs_1.existsSync)(resolvedPath)) { return resolvedPath; } // If file doesn't exist, try to find it in project config directories const configDir = (0, path_1.join)((0, os_1.homedir)(), '.route-claude-code'); const configReleaseDir = (0, path_1.join)((0, os_1.homedir)(), '.claude-code-router'); // Try .route-claude-code directory first const configPath = (0, path_1.join)(configDir, (0, path_1.basename)(filePath)); if ((0, fs_1.existsSync)(configPath)) { return configPath; } // Try legacy .claude-code-router directory const legacyConfigPath = (0, path_1.join)(configReleaseDir, (0, path_1.basename)(filePath)); if ((0, fs_1.existsSync)(legacyConfigPath)) { return legacyConfigPath; } // If not found in config directories, return original resolved path return resolvedPath; } //# sourceMappingURL=path-resolver.js.map