Variables de entorno

This commit is contained in:
2026-03-23 15:47:38 +01:00
parent ff34e9b664
commit a141840f61
2 changed files with 6 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@sf-alvar/db-migrate",
"version": "1.0.3",
"version": "1.0.4",
"description": "Herramienta de migracion de bdd",
"main": "lib/index.js",
"engines": {

View File

@@ -27,8 +27,9 @@ type DBVersion = {
* Busca el .env en el directorio actual (CWD)
*/
async function loadEnv(envpath?: string) {
const envPath = envpath ?? path.join(process.cwd(), '.env');
if (existsSync(envPath)) {
const env = process.env
const envPath = envpath;
if (envPath != undefined && existsSync(envPath)) {
const content = await fs.readFile(envPath, 'utf-8');
content.split('\n').forEach(line => {
const [key, value] = line.split('=');
@@ -36,6 +37,8 @@ async function loadEnv(envpath?: string) {
});
console.log('[i] Archivo .env cargado desde ' + envpath);
console.log("ENV:", env)
} else {
console.log("[i] Variables de entorno locales")
}
}