Comparing version 0.0.5-beta to 0.0.6-beta
@@ -305,3 +305,9 @@ var fs = require("fs"); | ||
output_path[0] = config.output_dir; | ||
fs.mkdirSync(output_path.join("/")); | ||
fs.stat(config.output_dir, function(err, stats){ | ||
if(err || !stats.isDirectory()){ | ||
// Create the output directory | ||
fs.mkdirSync(output_path.join("/")); | ||
} | ||
}); | ||
} | ||
@@ -308,0 +314,0 @@ |
@@ -5,3 +5,3 @@ { | ||
, "keywords": ["static", "sites", "mustache", "json", "markdown"] | ||
, "version": "0.0.5-beta" | ||
, "version": "0.0.6-beta" | ||
, "homepage": "https://github.com/laktek/punch" | ||
@@ -8,0 +8,0 @@ , "author": "Lakshan Perera <lakshan@web2media.net> (http://laktek.com)" |
@@ -98,4 +98,7 @@ var util = require("util"); | ||
}); | ||
spyOn(fs, 'stat').andCallFake(function(path, callback){ | ||
callback(null, {isDirectory: function(){ return true }} ); | ||
}); | ||
spyOn(fs, 'mkdirSync'); | ||
spyOn(punch, "fetchAndRender"); | ||
@@ -112,2 +115,6 @@ | ||
spyOn(fs, 'stat').andCallFake(function(path, callback){ | ||
callback(null, {isDirectory: function(){ return false }} ); | ||
}); | ||
spyOn(fs, 'mkdirSync'); | ||
@@ -130,2 +137,26 @@ spyOn(punch, "fetchAndRender"); | ||
it("will skip creating already existing sub-directories in the output path", function(){ | ||
var config = {"template_dir": "templates", "output_dir": "public"}; | ||
spyOn(fs, 'stat').andCallFake(function(path, callback){ | ||
callback(null, {isDirectory: function(){ return true }} ); | ||
}); | ||
spyOn(fs, 'mkdirSync'); | ||
spyOn(punch, "fetchAndRender"); | ||
spyOn(fs, 'readdir').andCallFake(function(path, callback){ | ||
if(fs.readdir.mostRecentCall.args[0] === "templates"){ | ||
callback(null, ["index.mustache", "sub_dir"]); | ||
} else { | ||
callback(null, ["sub.mustache"]); | ||
} | ||
}); | ||
punch.traverseTemplates(config); | ||
expect(fs.mkdirSync).not.toHaveBeenCalled(); | ||
}); | ||
it("calls to render content when a template is found", function(){ | ||
@@ -142,3 +173,6 @@ var config = {"template_dir": "templates"}; | ||
spyOn(fs, 'mkdirSync'); | ||
spyOn(fs, 'stat').andCallFake(function(path, callback){ | ||
callback(null, {isDirectory: function(){ return true }} ); | ||
}); | ||
spyOn(punch, "fetchAndRender"); | ||
@@ -163,3 +197,6 @@ | ||
spyOn(fs, 'mkdirSync'); | ||
spyOn(fs, 'stat').andCallFake(function(path, callback){ | ||
callback(null, {isDirectory: function(){ return true }} ); | ||
}); | ||
spyOn(punch, "fetchAndRender"); | ||
@@ -185,3 +222,2 @@ | ||
spyOn(fs, 'mkdirSync'); | ||
spyOn(punch, "staticFileHandler"); | ||
@@ -195,3 +231,2 @@ | ||
}); | ||
@@ -198,0 +233,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
40965
970