Просмотр исходного кода

Ensure to require some files for live reloading

Yuki Takei 8 лет назад
Родитель
Сommit
6586589e64
1 измененных файлов с 16 добавлено и 0 удалено
  1. 16 0
      lib/crowi/dev.js

+ 16 - 0
lib/crowi/dev.js

@@ -1,4 +1,5 @@
 const debug = require('debug')('crowi:crowi:dev');
 const debug = require('debug')('crowi:crowi:dev');
+const fs = require('fs');
 const path = require('path');
 const path = require('path');
 const webpack = require('webpack');
 const webpack = require('webpack');
 const helpers = require('./helpers');
 const helpers = require('./helpers');
@@ -20,6 +21,8 @@ class CrowiDev {
   }
   }
 
 
   init() {
   init() {
+    this.requireForLiveReload();
+
     this.initPromiseRejectionWarningHandler();
     this.initPromiseRejectionWarningHandler();
     this.initSwig();
     this.initSwig();
     this.hackLRWebSocketServer();
     this.hackLRWebSocketServer();
@@ -34,6 +37,19 @@ class CrowiDev {
     swig.setDefaults({ cache: false });
     swig.setDefaults({ cache: false });
   }
   }
 
 
+  /**
+   * require files for live reloading
+   */
+  requireForLiveReload() {
+    // environment file
+    require(path.join(this.crowi.rootDir, 'config', 'env.dev.js'));
+
+    // load all json files for live reloading
+    fs.readdirSync(this.crowi.localeDir).map((dirname) => {
+      require(path.join(this.crowi.localeDir, dirname, 'translation.json'));
+    });
+  }
+
   /**
   /**
    * prevent to crash socket with:
    * prevent to crash socket with:
    * -------------------------------------------------
    * -------------------------------------------------