Permalink
Browse files

Replace f.mkdirs with mkdirp due to dirs not being created on Windows.

  • Loading branch information...
cliffano committed Aug 15, 2012
1 parent 8ec364e commit f3a1f55891fa90488f04b9dc13ce9342e1407008
Showing with 13 additions and 13 deletions.
  1. +2 −1 lib/engine.js
  2. +1 −0 package.json
  3. +10 −12 test/engine.js
View
@@ -1,5 +1,6 @@
var _ = require('underscore'),
async = require('async'),
+ mkdirp = require('mkdirp'),
f = require('file'),
fs = require('fs'),
functions = require('./functions'),
@@ -112,7 +113,7 @@ Engine.prototype.merge = function (dir, templates, params, cb) {
}
function _writePage(cb) {
- f.mkdirs(p.join(dir, page).replace(/(\/[^\/]+$|\\[^\\]+$)/, ''), '0755', function (err) {
+ mkdirp(p.join(dir, page).replace(/(\/[^\/]+$|\\[^\\]+$)/, ''), '0755', function (err) {
if (!err) {
fs.writeFile(p.join(dir, page), pageContent, 'utf8', function (err) {
if (!err) {
View
@@ -34,6 +34,7 @@
"dateformat": "1.0.2-1.2.3",
"file": "0.2.1",
"jazz": "0.0.18",
+ "mkdirp": "0.3.3",
"ncp": "0.2.6",
"underscore": "1.3.3",
"watch-tree-maintained": "0.1.2",
View
@@ -105,12 +105,10 @@ describe('engine', function () {
cb(mocks.fs_writeFile_err);
}
},
- file: {
- mkdirs: function (dir, mode, cb) {
- checks.file_mkdirs_dir = dir;
- mode.should.equal('0755');
- cb(mocks.file_mkdirs_err);
- }
+ mkdirp: function (dir, mode, cb) {
+ checks.mkdirp_dir = dir;
+ mode.should.equal('0755');
+ cb(mocks.mkdirp_err);
}
};
});
@@ -205,11 +203,11 @@ describe('engine', function () {
});
checks.console_log_messages.length.should.equal(1);
checks.console_log_messages[0].should.equal('+ creating some/output/dir/page.html');
- checks.file_mkdirs_dir.should.equal('some/output/dir');
+ checks.mkdirp_dir.should.equal('some/output/dir');
});
it('should pass error to callback when directory cannot be created', function (done) {
- mocks.file_mkdirs_err = new Error('someerror');
+ mocks.mkdirp_err = new Error('someerror');
var templates = {
partials: {
},
@@ -230,11 +228,11 @@ describe('engine', function () {
done();
});
checks.engine_compile_err.message.should.equal('someerror');
- checks.file_mkdirs_dir.should.equal('some/output/dir');
+ checks.mkdirp_dir.should.equal('some/output/dir');
});
it('should create dir with *nix and Windows paths', function () {
- mocks.file_mkdirs_err = new Error('someerror');
+ mocks.mkdirp_err = new Error('someerror');
var templates = {
partials: {
},
@@ -252,11 +250,11 @@ describe('engine', function () {
engine.merge('some/output/dir', templates, params, function (err, result) {
});
- checks.file_mkdirs_dir.should.equal('some/output/dir');
+ checks.mkdirp_dir.should.equal('some/output/dir');
engine.merge('some\\output\\dir', templates, params, function (err, result) {
});
- checks.file_mkdirs_dir.should.equal('some\\output');
+ checks.mkdirp_dir.should.equal('some\\output');
});
});
});

0 comments on commit f3a1f55

Please sign in to comment.