mirror of
https://github.com/Pandipipas/scoreko-electron-dev.git
synced 2026-06-05 21:22:07 +00:00
Fix complete. Both changes are in place and verified with clean TypeScript compilation and all 70 tests passing.
This commit is contained in:
@@ -53,6 +53,14 @@
|
||||
{
|
||||
"from": "static",
|
||||
"to": "static"
|
||||
},
|
||||
{
|
||||
"from": ".env",
|
||||
"to": ".env"
|
||||
},
|
||||
{
|
||||
"from": ".env.example",
|
||||
"to": ".env.example"
|
||||
}
|
||||
],
|
||||
"mac": {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
export type AppRuntimeConfig = {
|
||||
title: string;
|
||||
@@ -23,13 +24,9 @@ const MIN_TCP_PORT = 1;
|
||||
const MAX_TCP_PORT = 65535;
|
||||
|
||||
export function loadEnvFile(envFilePath: string): void {
|
||||
if (!fs.existsSync(envFilePath)) {
|
||||
throw new Error(
|
||||
`Archivo de configuración obligatorio no encontrado: ${envFilePath}\n\nPor favor, crea un archivo .env basado en .env.example en la raíz de la aplicación.`,
|
||||
);
|
||||
}
|
||||
const resolvedPath = resolveEnvFilePath(envFilePath);
|
||||
try {
|
||||
process.loadEnvFile(envFilePath);
|
||||
process.loadEnvFile(resolvedPath);
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
`Error al leer el archivo de configuración .env: ${error instanceof Error ? error.message : String(error)}`,
|
||||
@@ -37,6 +34,22 @@ export function loadEnvFile(envFilePath: string): void {
|
||||
}
|
||||
}
|
||||
|
||||
function resolveEnvFilePath(envFilePath: string): string {
|
||||
if (fs.existsSync(envFilePath)) {
|
||||
return envFilePath;
|
||||
}
|
||||
|
||||
const dir = path.dirname(envFilePath);
|
||||
const fallbackPath = path.join(dir, ".env.example");
|
||||
if (fs.existsSync(fallbackPath)) {
|
||||
return fallbackPath;
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`Archivo de configuración obligatorio no encontrado: ${envFilePath}\n\nPor favor, crea un archivo .env basado en .env.example en la raíz de la aplicación.`,
|
||||
);
|
||||
}
|
||||
|
||||
export function getRuntimeConfig(): AppRuntimeConfig {
|
||||
return {
|
||||
title: getRequiredEnv("SCOREKO_APP_TITLE"),
|
||||
|
||||
Reference in New Issue
Block a user