fix(Qenv): Fix file path initialization for environment variable files

This commit is contained in:
2024-11-18 19:23:35 +01:00
parent fdd4fc62c2
commit ec68a4db92
3 changed files with 16 additions and 3 deletions

View File

@@ -37,17 +37,24 @@ export class Qenv {
plugins.path.resolve(envFileBasePathArg),
'env.json'
);
const envFileYamlPath = this.envFilePathAbsolute = plugins.path.join(
const envFileYmlPath = this.envFilePathAbsolute = plugins.path.join(
plugins.path.resolve(envFileBasePathArg),
'env.yml'
);
const envFileYamlPath = this.envFilePathAbsolute = plugins.path.join(
plugins.path.resolve(envFileBasePathArg),
'env.yaml'
);
const envFileJsonExists = plugins.smartfile.fs.fileExistsSync(envFileJsonPath);
const envFileYmlExists = plugins.smartfile.fs.fileExistsSync(envFileYmlPath);
const envFileYamlExists = plugins.smartfile.fs.fileExistsSync(envFileYamlPath);
if (envFileJsonExists && envFileYamlExists) {
if (envFileJsonExists && (envFileYamlExists || envFileYmlExists)) {
this.logger.log('warn', 'Both env.json and env.yml files exist! Using env.json');
} else if (envFileJsonExists) {
this.envFilePathAbsolute = envFileJsonPath;
} else if (envFileYmlExists) {
this.envFilePathAbsolute = envFileYmlPath;
} else if (envFileYamlExists) {
this.envFilePathAbsolute = envFileYamlPath;
}