Comparing version 0.1.4 to 0.1.5
@@ -10,7 +10,7 @@ (function () { | ||
/** | ||
* Offers functionality similar to mkdir -p | ||
* | ||
* Asynchronous operation. No arguments other than a possible exception | ||
* are given to the completion callback. | ||
*/ | ||
* Offers functionality similar to mkdir -p | ||
* | ||
* Asynchronous operation. No arguments other than a possible exception | ||
* are given to the completion callback. | ||
*/ | ||
function mkdir_p (path, mode, callback, position) { | ||
@@ -32,3 +32,3 @@ var parts = require('path').normalize(path).split(osSep); | ||
mkdirOrig(directory, mode, function (err) { | ||
if (err && err.errno != 17) { | ||
if (err && err.code != 'EEXIST') { | ||
return callback(err); | ||
@@ -62,3 +62,3 @@ } else { | ||
} catch (e) { | ||
if (e.errno != 17) { | ||
if (e.code != 'EEXIST') { | ||
throw e; | ||
@@ -72,7 +72,7 @@ } | ||
/** | ||
* Polymorphic approach to fs.mkdir() | ||
* | ||
* If the third parameter is boolean and true assume that | ||
* caller wants recursive operation. | ||
*/ | ||
* Polymorphic approach to fs.mkdir() | ||
* | ||
* If the third parameter is boolean and true assume that | ||
* caller wants recursive operation. | ||
*/ | ||
fs.mkdir = function (path, mode, recursive, callback) { | ||
@@ -96,7 +96,7 @@ if (typeof recursive !== 'boolean') { | ||
/** | ||
* Polymorphic approach to fs.mkdirSync() | ||
* | ||
* If the third parameter is boolean and true assume that | ||
* caller wants recursive operation. | ||
*/ | ||
* Polymorphic approach to fs.mkdirSync() | ||
* | ||
* If the third parameter is boolean and true assume that | ||
* caller wants recursive operation. | ||
*/ | ||
fs.mkdirSync = function (path, mode, recursive) { | ||
@@ -103,0 +103,0 @@ if (typeof recursive !== 'boolean') { |
{ | ||
"name": "node-fs", | ||
"description": "node-fs is an extension to the original nodejs fs library, offering new functionalities.", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"author": "Bruno Pedro <bpedro@tarpipe.com>", | ||
@@ -6,0 +6,0 @@ |
@@ -6,2 +6,4 @@ node-fs is an extension to the original [nodejs](http://nodejs.org) [fs library](http://nodejs.org/docs/v0.3.1/api/fs.html), offering new functionalities. See example.js for an example of how to use it. | ||
* mkdir(path, mode, [recursive], [callback]): if the 'recursive' parameter is true, creates a directory recursively; | ||
* mkdirSync(path, mode, [recursive]): if the 'recursive' parameter is true, synchronously creates a directory recursively. | ||
* mkdirSync(path, mode, [recursive]): if the 'recursive' parameter is true, synchronously creates a directory recursively. | ||
[](http://travis-ci.org/bpedro/node-fs) |
var fs = require('../lib/fs'); | ||
var assert = require('assert'); | ||
// Define the base temporary directory where tests will be written | ||
var tmpBaseDir = '/tmp/_node-fs-test'; | ||
/** | ||
@@ -8,3 +11,3 @@ * Tests the recursive creation of a directory | ||
exports.testRecursiveMkdir = function() { | ||
fs.mkdir('/tmp/example_dir/first/second/third/fourth/fifth', 0777, true, function (err) { | ||
fs.mkdir(tmpBaseDir + '/a/b/c/d/e', 0777, true, function (err) { | ||
assert.isUndefined(err); | ||
@@ -14,8 +17,11 @@ }); | ||
exports.testRecursiveSyncMkdir = function() { | ||
try { | ||
fs.mkdirSync('/tmp/example_sync/first/second/third/fourth/fifth', 0777, true); | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
/** | ||
* Tests the synchronous creation of a directory | ||
*/ | ||
exports.testRecursiveMkdirSync = function() { | ||
assert.doesNotThrow( | ||
function () { | ||
fs.mkdirSync(tmpBaseDir + '/_sync/a/b/c/d/e', 0777, true); | ||
} | ||
); | ||
} |
6382
7
146
9