chore: sync submodule state (parent ref update)
Made-with: Cursor
This commit is contained in:
26
index.js
26
index.js
@@ -9,14 +9,19 @@ import crypto from 'crypto';
|
||||
import { readFileSync } from 'fs';
|
||||
import { join, dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { homedir } from 'os';
|
||||
|
||||
// Load environment variables from .env file
|
||||
// Load environment variables from ~/.env file (standardized location)
|
||||
const envPath = join(homedir(), '.env');
|
||||
|
||||
// Also try relative path as fallback for backwards compatibility
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const envPath = join(__dirname, '../.env');
|
||||
const envPathFallback = join(__dirname, '../.env');
|
||||
|
||||
try {
|
||||
const envFile = readFileSync(envPath, 'utf8');
|
||||
function loadEnvFile(filePath) {
|
||||
try {
|
||||
const envFile = readFileSync(filePath, 'utf8');
|
||||
const envVars = envFile.split('\n').filter(line => line.includes('=') && !line.trim().startsWith('#'));
|
||||
for (const line of envVars) {
|
||||
const [key, ...values] = line.split('=');
|
||||
@@ -30,8 +35,17 @@ try {
|
||||
process.env[key.trim()] = value;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Warning: Could not load .env file:', error.message);
|
||||
return true;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Try ~/.env first, then fallback to relative path
|
||||
if (!loadEnvFile(envPath)) {
|
||||
if (!loadEnvFile(envPathFallback)) {
|
||||
console.error('Warning: Could not load .env file from ~/.env or ../.env');
|
||||
}
|
||||
}
|
||||
|
||||
class ProxmoxServer {
|
||||
|
||||
Reference in New Issue
Block a user