Skip to content
Browse files

pass the path to generator hooks even if the file is not modified

  • Loading branch information...
1 parent eec1752 commit 0f136f2d5692edba692fddf326bcfbb7ed4739aa @laktek committed Nov 10, 2012
Showing with 14 additions and 9 deletions.
  1. +7 −2 lib/generator_hooks/console_output.js
  2. +6 −6 lib/site_generator.js
  3. +1 −1 spec/site_generator.spec.js
View
9 lib/generator_hooks/console_output.js
@@ -1,8 +1,13 @@
module.exports = {
- run: function(file_path, complete, callback) {
- if (file_path) {
+ run: function(file_path, options, callback) {
+ var modified = options.modified || false;
+ var finished = options.finished || false;
+
+ if (file_path && modified) {
console.log("Created " + file_path);
+ } else if (file_path && !modified) {
+ console.log("Not modified " + file_path);
}
return callback();
View
12 lib/site_generator.js
@@ -159,18 +159,18 @@ module.exports = {
var options = {};
- var store_if_modified = function(rendered_obj){
+ var store_if_modified = function(rendered_obj) {
if(rendered_obj.modified){
self.cacheStore.update(request_basename, file_extension, rendered_obj, options, function(err) {
if (err) {
// we do nothing here.
// maybe log the failure?
}
- return callback(request_path);
+ return callback(request_path, true);
});
} else {
- return callback();
+ return callback(request_path, false);
}
};
@@ -185,8 +185,8 @@ module.exports = {
var move_to_next_path = function() {
if (paths.length) {
- return self.renderPath(paths.pop(), function(rendered_path) {
- return self.runGeneratorHooks(rendered_path, false, move_to_next_path);
+ return self.renderPath(paths.pop(), function(rendered_path, modified) {
+ return self.runGeneratorHooks(rendered_path, { modified: true }, move_to_next_path);
});
} else {
return callback();
@@ -244,7 +244,7 @@ module.exports = {
return steps.shift().apply(self, method_args);
} else {
var run_generator_hooks = function(complete) {
- return self.runGeneratorHooks(null, true, complete);
+ return self.runGeneratorHooks(null, { finished: true }, complete);
};
return run_generator_hooks(complete);
View
2 spec/site_generator.spec.js
@@ -208,7 +208,7 @@ describe("generate site", function() {
var spyCallback = jasmine.createSpy();
site_generator.generate(spyCallback);
- expect(site_generator.runGeneratorHooks).toHaveBeenCalledWith(null, true, spyCallback);
+ expect(site_generator.runGeneratorHooks).toHaveBeenCalledWith(null, { finished: true }, spyCallback);
});
it("call the user provided callback", function() {

0 comments on commit 0f136f2

Please sign in to comment.
Something went wrong with that request. Please try again.