Skip to content

Commit

Permalink
fixed a pretty significant bug with project recompiling and file addi…
Browse files Browse the repository at this point in the history
…tion/deletion
  • Loading branch information
Jeff Escalante committed Feb 20, 2013
1 parent f767d58 commit 90f0f6f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/commands/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ var _watch = function(){
// for another non-ignored file. Until we have something like assetgraph
// in this project, the safest approach is to recompile the whole project
// when an ignored file is modified.

var ignored = global.options.ignore_files;

for (var i = 0; i < ignored.length; i++){
if (!minimatch(file.path, ignored[i])) {
if (minimatch(path.basename(file.path), ignored[i])) {
return roots.compile_project(current_directory, server.reload);
}
}
Expand Down
4 changes: 4 additions & 0 deletions lib/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ Compiler.prototype.finish = function(){
Compiler.prototype.compile = function(file, cb){
var adapter = get_adapter_by_extension(path.extname(file).slice(1));
var self = this;
// compile should return the compiled content
// once it goes to the compile helper, that needs to strip the
// front matter and add it as locals
adapter.compile(file, Helper, function(err){
if (err) { return self.emit('error', err); }
// write the actual file here
cb();
});
};
Expand Down
2 changes: 0 additions & 2 deletions lib/precompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ module.exports = function(){
deferred.resolve();
});

console.log('tmpl-precompile is locking the process... what?');

return deferred.promise;

}
3 changes: 3 additions & 0 deletions lib/utils/compile_helper.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ module.exports = class CompileHelper
@target_extension = path.extname(@export_path).slice(1)
@file_contents = fs.readFileSync(@file, 'utf8')

# parse front matter, pull out locals and add them to the class
# set alternate layout if necessary

# handling for layouts
if @target_extension == 'html'
@layout = options.layouts.default
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/configure_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = function(cb){
if (!options.layouts) {options.layouts = {}; }

for (var key in options.layouts){
options.ignore_files.push(new RegExp(options.layouts[key]));
options.ignore_files.push(options.layouts[key]);
}

// not compiled by default
Expand Down
7 changes: 6 additions & 1 deletion lib/watcher.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
var Monocle = require('monocle');

function watch_directory(dir, cb) {
(new Monocle).watchDirectory(dir, cb, undefined, 'app.coffee', ['!components', '!public', '!plugins']);
(new Monocle).watchDirectory({
root: dir,
callback: cb,
fileFilter: 'app.coffee',
directoryFilter: ['!components', '!public', '!plugins']
});
}

exports.watch_directory = watch_directory;

0 comments on commit 90f0f6f

Please sign in to comment.