Bläddra i källkod

Merge branch 'fix-env-file' of si/dockerize-project into master

Sistemi Informatici 3 år sedan
förälder
incheckning
e6f7f5af6a
3 ändrade filer med 25 tillägg och 15 borttagningar
  1. 17 3
      bin/classes/ProjectEnvironment.js
  2. 0 1
      bin/commands/stop.js
  3. 8 11
      package.json

+ 17 - 3
bin/classes/ProjectEnvironment.js

@@ -9,10 +9,10 @@ class ProjectEnvironment {
     this._env = env;
 
     this._dockerOptions = {
-      cwd: cwd,
       config: [
         'docker-compose.yml'
       ],
+      cwd: cwd,
       log: true
     };
 
@@ -32,8 +32,6 @@ class ProjectEnvironment {
     const configFilename = `config.${this._env}.json`;
     const configFilepath = path.join(this._cwd, configFilename);
 
-    console.log(configFilepath);
-
     if (!fs.existsSync(configFilepath)) {
       return false;
     }
@@ -58,6 +56,22 @@ class ProjectEnvironment {
 
     this._dockerOptions.config.push(dockerComposeFilename);
 
+    let envFilename = `.env.${this._env}`;
+    let envFilepath = path.join(this._cwd, envFilename);
+
+    if (!fs.existsSync(envFilepath)) {
+      envFilename = `.env`;
+      envFilepath = path.join(this._cwd, envFilename);
+
+      if (!fs.existsSync(envFilepath)) {
+        envFilename = false;
+      }
+    }
+
+    if (envFilename) {
+      this._dockerOptions.composeOptions = [["--env-file", envFilename]];
+    }
+
     return true;
   }
 

+ 0 - 1
bin/commands/stop.js

@@ -1,4 +1,3 @@
-const path = require('path');
 const isRoot = require('is-root');
 const hostile = require('hostile');
 const colors = require('colors');

+ 8 - 11
package.json

@@ -1,5 +1,5 @@
 {
-  "_from": "git+http://git.makemoneyorganization.com:3000/si/dockerize-project.git",
+  "_from": "git+http://git.makemoneyorganization.com/si/dockerize-project.git",
   "_id": "dockerize-project@2.1.1",
   "_inBundle": false,
   "_integrity": "",
@@ -7,19 +7,19 @@
   "_phantomChildren": {},
   "_requested": {
     "type": "git",
-    "raw": "dockerize-project@git+http://git.makemoneyorganization.com:3000/si/dockerize-project.git",
+    "raw": "dockerize-project@git+http://git.makemoneyorganization.com/si/dockerize-project.git",
     "name": "dockerize-project",
     "escapedName": "dockerize-project",
-    "rawSpec": "git+http://git.makemoneyorganization.com:3000/si/dockerize-project.git",
-    "saveSpec": "git+http://git.makemoneyorganization.com:3000/si/dockerize-project.git",
-    "fetchSpec": "http://git.makemoneyorganization.com:3000/si/dockerize-project.git",
+    "rawSpec": "git+http://git.makemoneyorganization.com/si/dockerize-project.git",
+    "saveSpec": "git+http://git.makemoneyorganization.com/si/dockerize-project.git",
+    "fetchSpec": "http://git.makemoneyorganization.com/si/dockerize-project.git",
     "gitCommittish": "v2.1.1"
   },
   "_requiredBy": [
     "#DEV:/"
   ],
-  "_resolved": "git+http://git.makemoneyorganization.com:3000/si/dockerize-project.git",
-  "_spec": "dockerize-project@git+http://git.makemoneyorganization.com:3000/si/dockerize-project.git",
+  "_resolved": "git+http://git.makemoneyorganization.com/si/dockerize-project.git",
+  "_spec": "dockerize-project@git+http://git.makemoneyorganization.com/si/dockerize-project.git",
   "_where": "/home/mdomenici/Progetti/bc",
   "author": {
     "name": "MirkoDomenici"
@@ -42,10 +42,7 @@
   "name": "dockerize-project",
   "repository": {
     "type": "git",
-    "url": "http://git.dev.makemoneyorganization.com:3000/si/dockerize-project.git"
-  },
-  "scripts": {
-    "test": "echo \"Error: no test specified\" && exit 1"
+    "url": "http://git.dev.makemoneyorganization.com/si/dockerize-project.git"
   },
   "version": "2.1.1"
 }