Comparing version 0.0.6-beta to 0.0.7-beta
@@ -306,8 +306,12 @@ var fs = require("fs"); | ||
fs.stat(config.output_dir, function(err, stats){ | ||
if(err || !stats.isDirectory()){ | ||
// Create the output directory | ||
fs.mkdirSync(output_path.join("/")); | ||
} | ||
}); | ||
try { | ||
// Create the output directory | ||
fs.mkdirSync(output_path.join("/")); | ||
} | ||
catch(err){ | ||
// we can ignore the errors | ||
// since failing to create a directory means | ||
// it already exists. | ||
// or destination is not writeable. | ||
} | ||
} | ||
@@ -314,0 +318,0 @@ |
@@ -5,3 +5,3 @@ { | ||
, "keywords": ["static", "sites", "mustache", "json", "markdown"] | ||
, "version": "0.0.6-beta" | ||
, "version": "0.0.7-beta" | ||
, "homepage": "https://github.com/laktek/punch" | ||
@@ -8,0 +8,0 @@ , "author": "Lakshan Perera <lakshan@web2media.net> (http://laktek.com)" |
@@ -98,7 +98,4 @@ var util = require("util"); | ||
}); | ||
spyOn(fs, 'stat').andCallFake(function(path, callback){ | ||
callback(null, {isDirectory: function(){ return true }} ); | ||
}); | ||
spyOn(fs, 'mkdirSync'); | ||
spyOn(punch, "fetchAndRender"); | ||
@@ -115,6 +112,2 @@ | ||
spyOn(fs, 'stat').andCallFake(function(path, callback){ | ||
callback(null, {isDirectory: function(){ return false }} ); | ||
}); | ||
spyOn(fs, 'mkdirSync'); | ||
@@ -137,26 +130,2 @@ 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(){ | ||
@@ -173,6 +142,3 @@ var config = {"template_dir": "templates"}; | ||
spyOn(fs, 'stat').andCallFake(function(path, callback){ | ||
callback(null, {isDirectory: function(){ return true }} ); | ||
}); | ||
spyOn(fs, 'mkdirSync'); | ||
spyOn(punch, "fetchAndRender"); | ||
@@ -197,6 +163,3 @@ | ||
spyOn(fs, 'stat').andCallFake(function(path, callback){ | ||
callback(null, {isDirectory: function(){ return true }} ); | ||
}); | ||
spyOn(fs, 'mkdirSync'); | ||
spyOn(punch, "fetchAndRender"); | ||
@@ -222,2 +185,3 @@ | ||
spyOn(fs, 'mkdirSync'); | ||
spyOn(punch, "staticFileHandler"); | ||
@@ -231,2 +195,3 @@ | ||
}); | ||
@@ -233,0 +198,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
39929
949