Explorar el Código

ensure to init Crowi.env with process.env autonomously

Yuki Takei hace 7 años
padre
commit
ad0c365747
Se han modificado 3 ficheros con 8 adiciones y 8 borrados
  1. 1 1
      src/server/app.js
  2. 2 2
      src/server/crowi/index.js
  3. 5 5
      src/test/crowi/crowi.test.js

+ 1 - 1
src/server/app.js

@@ -9,7 +9,7 @@ require('module-alias/register');
 
 
 const logger = require('@alias/logger')('growi');
 const logger = require('@alias/logger')('growi');
 const helpers = require('@commons/util/helpers');
 const helpers = require('@commons/util/helpers');
-const growi = new (require('./crowi'))(helpers.root(), process.env);
+const growi = new (require('./crowi'))(helpers.root());
 
 
 
 
 /************************************
 /************************************

+ 2 - 2
src/server/crowi/index.js

@@ -15,7 +15,7 @@ const debug = require('debug')('growi:crowi')
 
 
   ;
   ;
 
 
-function Crowi(rootdir, env) {
+function Crowi(rootdir) {
   const self = this;
   const self = this;
 
 
   this.version = pkg.version;
   this.version = pkg.version;
@@ -45,7 +45,7 @@ function Crowi(rootdir, env) {
 
 
   this.models = {};
   this.models = {};
 
 
-  this.env = env;
+  this.env = process.env;
   this.node_env = this.env.NODE_ENV || 'development';
   this.node_env = this.env.NODE_ENV || 'development';
 
 
   this.port = this.env.PORT || 3000;
   this.port = this.env.PORT || 3000;

+ 5 - 5
src/test/crowi/crowi.test.js

@@ -13,21 +13,21 @@ describe('Test for Crowi application context', function() {
 
 
   describe('construction', function() {
   describe('construction', function() {
     it('initialize crowi context', function() {
     it('initialize crowi context', function() {
-      const crowi = new Crowi(helpers.root(), process.env);
+      const crowi = new Crowi(helpers.root());
       expect(crowi).to.be.instanceof(Crowi);
       expect(crowi).to.be.instanceof(Crowi);
       expect(crowi.version).to.equal(require('../../../package.json').version);
       expect(crowi.version).to.equal(require('../../../package.json').version);
       expect(crowi.env).to.be.an('Object');
       expect(crowi.env).to.be.an('Object');
     });
     });
 
 
     it('config getter, setter', function() {
     it('config getter, setter', function() {
-      const crowi = new Crowi(helpers.root(), process.env);
+      const crowi = new Crowi(helpers.root());
       expect(crowi.getConfig()).to.deep.equals({});
       expect(crowi.getConfig()).to.deep.equals({});
       crowi.setConfig({test: 1});
       crowi.setConfig({test: 1});
       expect(crowi.getConfig()).to.deep.equals({test: 1});
       expect(crowi.getConfig()).to.deep.equals({test: 1});
     });
     });
 
 
     it('model getter, setter', function() {
     it('model getter, setter', function() {
-      const crowi = new Crowi(helpers.root(), process.env);
+      const crowi = new Crowi(helpers.root());
       // set
       // set
       crowi.model('hoge', { fuga: 1 });
       crowi.model('hoge', { fuga: 1 });
       expect(crowi.model('hoge')).to.deep.equals({ fuga: 1 });
       expect(crowi.model('hoge')).to.deep.equals({ fuga: 1 });
@@ -39,9 +39,9 @@ describe('Test for Crowi application context', function() {
       mongoose.disconnect(); // avoid error of Trying to open unclosed connection
       mongoose.disconnect(); // avoid error of Trying to open unclosed connection
     });
     });
     it('setup completed', function(done) {
     it('setup completed', function(done) {
-      const crowi = new Crowi(helpers.root(), process.env);
+      const crowi = new Crowi(helpers.root());
       // set
       // set
-      const p = crowi.setupDatabase()
+      const p = crowi.setupDatabase();
       expect(p).to.instanceof(Promise);
       expect(p).to.instanceof(Promise);
       p.then(function() {
       p.then(function() {
         expect(mongoose.connection.readyState).to.equals(1);
         expect(mongoose.connection.readyState).to.equals(1);