diff --git a/src/utils/path.ts b/src/utils/path.ts index b3b6efa..b8dbdde 100644 --- a/src/utils/path.ts +++ b/src/utils/path.ts @@ -16,8 +16,9 @@ const rootDir = dirname(dirname(__dirname)); * @returns The path to the file */ export const getConfigFilePath = (filename: string, description = 'Configuration'): string => { - // Try to find the correct path to the file + const envPath = process.env.MCPHUB_SETTING_PATH; const potentialPaths = [ + ...(envPath ? [envPath] : []), // Prioritize process.cwd() as the first location to check path.resolve(process.cwd(), filename), // Use path relative to the root directory @@ -25,13 +26,13 @@ export const getConfigFilePath = (filename: string, description = 'Configuration // If installed with npx, may need to look one level up path.join(dirname(rootDir), filename) ]; - + for (const filePath of potentialPaths) { if (fs.existsSync(filePath)) { return filePath; } } - + // If all paths do not exist, use default path // Using the default path is acceptable because it ensures the application can proceed // even if the configuration file is missing. This fallback is particularly useful in