fix: update setup-couchdb.js path resolution for container environment

- Fix backendPath to work when script is in backend/scripts/
- Make .env loading conditional (exists check)
- Update both backend/scripts/ and scripts/ versions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
William Valentin
2025-12-06 14:05:46 -08:00
parent cde4850650
commit 1c26ed6723
2 changed files with 14 additions and 4 deletions

View File

@@ -2,12 +2,17 @@
// Setup module path to include backend node_modules
const path = require('path');
const backendPath = path.join(__dirname, '..', 'backend');
const backendPath = path.join(__dirname, '..');
process.env.NODE_PATH = path.join(backendPath, 'node_modules') + ':' + (process.env.NODE_PATH || '');
require('module').Module._initPaths();
const Nano = require('nano');
require('dotenv').config({ path: path.join(backendPath, '.env') });
// Load .env file if it exists (for local development)
const dotenvPath = path.join(backendPath, '.env');
const fs = require('fs');
if (fs.existsSync(dotenvPath)) {
require('dotenv').config({ path: dotenvPath });
}
// Configuration
const COUCHDB_URL = process.env.COUCHDB_URL || 'http://localhost:5984';