Comparing version 0.0.4-beta to 0.0.5-beta
@@ -327,2 +327,19 @@ var fs = require("fs"); | ||
prepareOutputDirectory: function(config){ | ||
var self = this; | ||
// Check whether the output directory exists | ||
fs.stat(config.output_dir, function(err, stats){ | ||
if(err || !stats.isDirectory()){ | ||
// Create the output directory | ||
fs.mkdirSync(config.output_dir); | ||
} | ||
// traverse templates | ||
self.traverseTemplates(config); | ||
}); | ||
}, | ||
generate: function(supplied_config){ | ||
@@ -360,10 +377,7 @@ | ||
// Create the output directory | ||
fs.mkdirSync(config.output_dir); | ||
// traverse templates | ||
self.traverseTemplates(config); | ||
// prepare output directory | ||
self.prepareOutputDirectory(config); | ||
} | ||
} |
@@ -5,3 +5,3 @@ { | ||
, "keywords": ["static", "sites", "mustache", "json", "markdown"] | ||
, "version": "0.0.4-beta" | ||
, "version": "0.0.5-beta" | ||
, "homepage": "https://github.com/laktek/punch" | ||
@@ -8,0 +8,0 @@ , "author": "Lakshan Perera <lakshan@web2media.net> (http://laktek.com)" |
@@ -35,2 +35,53 @@ var util = require("util"); | ||
describe("prepare output directory", function(){ | ||
it("creates the output directory if it doesn't exist", function(){ | ||
var config = {"template_dir": "templates"}; | ||
spyOn(fs, 'stat').andCallFake(function(path, callback){ | ||
callback(null, {isDirectory: function(){ return false }} ); | ||
}); | ||
spyOn(punch, "traverseTemplates"); | ||
spyOn(fs, "mkdirSync"); | ||
punch.prepareOutputDirectory(config); | ||
expect(fs.mkdirSync).toHaveBeenCalled(); | ||
}); | ||
it("will not create the output directory if it exists", function(){ | ||
var config = {"template_dir": "templates"}; | ||
spyOn(fs, 'stat').andCallFake(function(path, callback){ | ||
callback(null, {isDirectory: function(){ return true }} ); | ||
}); | ||
spyOn(punch, "traverseTemplates"); | ||
spyOn(fs, "mkdirSync"); | ||
punch.prepareOutputDirectory(config); | ||
expect(fs.mkdirSync).not.toHaveBeenCalled(); | ||
}); | ||
it("it calls to traverse templates", function(){ | ||
var config = {"template_dir": "templates"}; | ||
spyOn(fs, 'stat').andCallFake(function(path, callback){ | ||
callback(null, {isDirectory: function(){ return true }} ); | ||
}); | ||
spyOn(punch, "traverseTemplates"); | ||
punch.prepareOutputDirectory(config); | ||
expect(punch.traverseTemplates).toHaveBeenCalledWith(config); | ||
}); | ||
}); | ||
describe("traversing templates", function() { | ||
@@ -37,0 +88,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39641
940