Skip to content

Loading…

made file watching configurable #538

Merged
merged 2 commits into from

2 participants

@troyastorino

No description provided.

@mde
mde commented

This is awesome. I am wondering though if it would be better to have the default value in base_config.js be all empty values, and put the actual defaults directly in the development.js for generated apps. Two reasons -- file-watching is only active in development mode, and also, having it visible there in the generated config file would make it more obvious how this works, and make it much easier for people to tweak it for their own app. What do you think?

@troyastorino

That makes sense. That would mean placing it in gen/base/development.js I'm assuming?

@mde
mde commented

Yes, that's exactly right.

@troyastorino
@mde
mde commented

I'm not seeing any new commits on the PR.

@troyastorino

Hmm weird. It should be the 2nd commit in the PR. I made the comment a little while after the commit.

@mde
mde commented

Ah, there it is. Weird. Merging it now. :)

@mde mde merged commit eda4764 into geddy:master

1 check passed

Details default The Travis CI build passed
@mde
mde commented

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 5, 2014
  1. @troyastorino
Commits on Feb 6, 2014
  1. @troyastorino
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
12 gen/base/development.js
@@ -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
7 lib/base_config.js
@@ -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
17 lib/cluster/master.js
@@ -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 () {
Something went wrong with that request. Please try again.