Permalink
Browse files

Merge pull request #538 from troyastorino/master

made file watching configurable
  • Loading branch information...
mde committed Feb 7, 2014
2 parents bfa9f85 + 1fcdc87 commit eda47648277072ad30a71a2dc1cea7b76db5815d
Showing with 29 additions and 7 deletions.
  1. +12 −0 gen/base/development.js
  2. +7 −0 lib/base_config.js
  3. +10 −7 lib/cluster/master.js
View
@@ -20,6 +20,18 @@ var config = {
appName: 'Geddy App (development)'
, detailedErrors: true
, debug: true
+, watch: {
+ files : [
+ '/config'
+ , '/lib'
+ , '/app/controllers'
+ , '/app/models'
+ , '/app/views'
+ , '/app/helpers'
+ ]
+ , includePattern: '\\.(js|coffee|css|less|scss)$'
+ , excludePattern: '\\.git|node_modules'
+ }
, hostname: null
, port: 4000
, model: {
View
@@ -32,6 +32,13 @@ config = {
}
// Set stdout to debug log-level
, debug: false
+// List of files to watch in order to restart geddy on changes in
+// development environment. Set these in config/development.js
+, watch: {
+ files: []
+ , includePattern: ''
+ , excludePattern: ''
+}
// Use worker-process rotation
, rotateWorkers: true
// How long for a full rotation
View
@@ -196,15 +196,18 @@ Master.prototype = new (function () {
, dir = process.cwd()
, callback = function (file) {
_monitorProcesses.call(self, {manualRotate: true});
- };
+ }
+ , watchConfig = this.config.watch
+ , files = watchConfig.files
+ , opts = {
+ includePattern: new RegExp(watchConfig.includePattern)
+ , excludePattern: new RegExp(watchConfig.excludePattern)
+ };
// Watch individual files so we can compare mtimes and restart
// on code-changes
- file.watch(dir + '/config', callback);
- file.watch(dir + '/lib', callback);
- file.watch(dir + '/app/controllers', callback);
- file.watch(dir + '/app/models', callback);
- file.watch(dir + '/app/views', callback);
- file.watch(dir + '/app/helpers', callback);
+ for (var i = 0, ii = watchConfig.files.length; i < ii; i++) {
+ file.watch(dir + watchConfig.files[i], opts, callback);
+ }
};
this.init = function () {

0 comments on commit eda4764

Please sign in to comment.