Browse Source

Modificato per supporto senza file .env.yml

mdomenici 1 year ago
parent
commit
e4a77ea3af
1 changed files with 15 additions and 17 deletions
  1. 15 17
      bin/classes/ProjectEnvironment.js

+ 15 - 17
bin/classes/ProjectEnvironment.js

@@ -29,28 +29,26 @@ class ProjectEnvironment {
     const dockerComposeFilename = `docker-compose.${this._env}.yml`;
     const dockerComposeFilepath = path.join(this._cwd, dockerComposeFilename);
 
-    if (!fs.existsSync(dockerComposeFilepath)) {
-      return false;
-    }
-
-    this._dockerOptions.config.push(dockerComposeFilename);
-
-    let envFilename = `.env.${this._env}`;
-    let envFilepath = path.join(this._cwd, envFilename);
+    if (fs.existsSync(dockerComposeFilepath)) {
+      this._dockerOptions.config.push(dockerComposeFilename);
 
-    if (!fs.existsSync(envFilepath)) {
-      envFilename = `.env`;
-      envFilepath = path.join(this._cwd, envFilename);
+      let envFilename = `.env.${this._env}`;
+      let envFilepath = path.join(this._cwd, envFilename);
 
       if (!fs.existsSync(envFilepath)) {
-        envFilename = false;
+        envFilename = `.env`;
+        envFilepath = path.join(this._cwd, envFilename);
+
+        if (!fs.existsSync(envFilepath)) {
+          envFilename = false;
+        }
       }
-    }
 
-    if (envFilename) {
-      this._dockerOptions.composeOptions = [
-        ["--env-file", envFilename]
-      ];
+      if (envFilename) {
+        this._dockerOptions.composeOptions = [
+          ["--env-file", envFilename]
+        ];
+      }
     }
 
     return true;