Problema path
This commit is contained in:
17
lib/index.js
17
lib/index.js
@@ -16,16 +16,15 @@ const helpers_1 = require("yargs/helpers");
|
||||
* Busca el .env en el directorio actual (CWD)
|
||||
*/
|
||||
async function loadEnv(envpath) {
|
||||
const envPath = envpath ?? path_1.default.join(process.cwd(), '.env');
|
||||
if ((0, fs_1.existsSync)(envPath)) {
|
||||
const content = await promises_1.default.readFile(envPath, 'utf-8');
|
||||
content.split('\n').forEach(line => {
|
||||
const [key, value] = line.split('=');
|
||||
if (key && value)
|
||||
process.env[key.trim()] = value.trim();
|
||||
});
|
||||
const env = process.env;
|
||||
const envPath = envpath;
|
||||
if (envPath != undefined && (0, fs_1.existsSync)(envPath)) {
|
||||
process.loadEnvFile(envpath);
|
||||
console.log('[i] Archivo .env cargado desde ' + envpath);
|
||||
console.log("ENV:", process_1.env);
|
||||
console.log("ENV:", env);
|
||||
}
|
||||
else {
|
||||
console.log("[i] Variables de entorno locales");
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user