Reviewers: mp+136484_code.launchpad.net, Message: Please take a look.
Description: 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://code.launchpad.net/~makyo/juju-gui/editor-files/+merge/136484 (do not edit description out of merge proposal) Please review this at https://codereview.appspot.com/6842104/ Affected files: A [revision details] M lib/templates.js Index: [revision details] === added file '[revision details]' --- [revision details] 2012-01-01 00:00:00 +0000 +++ [revision details] 2012-01-01 00:00:00 +0000 @@ -0,0 +1,2 @@ +Old revision: [email protected] +New revision: [email protected] Index: lib/templates.js === modified file 'lib/templates.js' --- lib/templates.js 2012-11-15 21:53:49 +0000 +++ lib/templates.js 2012-11-27 18:25:01 +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]; -- 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. -- Mailing list: https://launchpad.net/~yellow Post to : [email protected] Unsubscribe : https://launchpad.net/~yellow More help : https://help.launchpad.net/ListHelp

