yellow team mailing list archive
-
yellow team
-
Mailing list archive
-
Message #01753
[Merge] lp:~makyo/juju-gui/editor-files into lp:juju-gui
Matthew Scott has proposed merging lp:~makyo/juju-gui/editor-files into lp:juju-gui.
Requested reviews:
Juju GUI Hackers (juju-gui)
Related bugs:
Bug #1083374 in juju-gui: "Directory watches do not ignore editor files"
https://bugs.launchpad.net/juju-gui/+bug/1083374
For more details, see:
https://code.launchpad.net/~makyo/juju-gui/editor-files/+merge/136484
Ignore editor files.
Watch functions will throw noisy errors on files created by editors, making debugging watched files (templates, LESS stylesheet) difficult in `make debug`; a validFile function was created to ignore these and slim down useless errors. Quick slack task.
https://codereview.appspot.com/6842104/
--
https://code.launchpad.net/~makyo/juju-gui/editor-files/+merge/136484
Your team Juju GUI Hackers is requested to review the proposed merge of lp:~makyo/juju-gui/editor-files into lp:juju-gui.
=== modified file 'lib/templates.js'
--- lib/templates.js 2012-11-15 21:53:49 +0000
+++ lib/templates.js 2012-11-27 18:28:22 +0000
@@ -120,6 +120,24 @@
});
}
+
+/**
+ * Determines whether a file is a valid file for processing. This should
+ * ignore all editor-created files in order to assist debugging. Included
+ * are files created by vim and emacs; feel free to add to this list.
+ *
+ * @param {string} filename The filename to check.
+ */
+function validFile(filename) {
+ if (filename.charAt(0) === '.' ||
+ filename.charAt(0) === '#' ||
+ filename.charAt(filename.length - 1) === '~' ||
+ filename === '4913') {
+ return false;
+ }
+ return true;
+}
+
var templateSpecs = {
templates: {
output: __dirname + '/../build/juju-ui/templates.js',
@@ -163,7 +181,7 @@
function watchTemplates(cb) {
fs.watch(config.server.template_dir, function(event, filename) {
//on dir change regen the cache
- if (filename.slice(0, 1) === '.') {return;}
+ if (!validFile(filename)) {return;}
var strategy = templateSpecs.templates;
strategy.callback(strategy, 'templates');
if (cb) {cb();}
@@ -175,7 +193,7 @@
function watchViews(cb) {
fs.watch(config.server.view_dir, function(event, filename) {
//on dir change regen the cache
- if (filename.slice(0, 1) === '.') {return;}
+ if (!validFile(filename)) {return;}
var ext = path.extname(filename),
basename = path.basename(filename, ext),
strategy = templateSpecs[basename];
Follow ups