Spaces:
Runtime error
Runtime error
Download src/database/load-cli-env.ts from MuhammadNoman7600/qwen_2.5_model: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/spaces/MuhammadNoman7600/qwen_2.5_model/resolve/main/src/database/load-cli-env.ts
- Command line
-
hf download hf://spaces/MuhammadNoman7600/qwen_2.5_model/src/database/load-cli-env.ts
-
curl -L -o load-cli-env.ts https://huggingface.co/spaces/MuhammadNoman7600/qwen_2.5_model/resolve/main/src/database/load-cli-env.ts
1.22 kB
| import { config } from 'dotenv'; | |
| import * as fs from 'fs'; | |
| import * as path from 'path'; | |
| import { getDataDirectory } from '../config/data-directory'; | |
| import { clearBlankEnv, BLANK_SHADOWED_ENV_KEYS } from '../config/env-precedence'; | |
| /** | |
| * Load environment for the standalone TypeORM CLI data-sources with the SAME precedence as | |
| * src/main.ts: `process.env` > `.env` > the configured data directory's `.env.generated` (all dotenv | |
| * `override: false`), with blank compose-forwarded keys cleared first. Without this, the migration CLI | |
| * ignored the dashboard-written configuration and ran against the default SQLite DB even when the | |
| * deployment was configured (via the dashboard) for PostgreSQL — i.e. `migration:run:prod` targeted | |
| * the wrong database. `cwd` is injectable for testing. | |
| */ | |
| export function loadCliEnv(cwd: string = process.cwd()): void { | |
| clearBlankEnv(process.env, BLANK_SHADOWED_ENV_KEYS); | |
| const userEnvPath = path.resolve(cwd, '.env'); | |
| const generatedEnvPath = path.join(getDataDirectory(cwd), '.env.generated'); | |
| if (fs.existsSync(userEnvPath)) config({ path: userEnvPath, override: false }); | |
| if (fs.existsSync(generatedEnvPath)) config({ path: generatedEnvPath, override: false }); | |
| } | |