yow
Advanced tools
Comparing version 1.0.10 to 1.0.11
{ | ||
"name": "yow", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "You Only Wish module", | ||
@@ -5,0 +5,0 @@ "main": "yow.js", |
var fs = require('fs'); | ||
var Path = require('path'); | ||
var mkpath = module.exports.mkpath = function(path) { | ||
// TODO: Create the entire path | ||
if (!fileExists(path)) { | ||
fs.mkdirSync(path); | ||
} | ||
} | ||
var fileExists = module.exports.fileExists = function(path) { | ||
@@ -25,10 +16,34 @@ | ||
var mkdir = module.exports.mkdir = function(path) { | ||
var mkdir = module.exports.mkdir = function(path, mode) { | ||
if (typeof mode === 'undefined') | ||
mode = 0777 & (~process.umask()); | ||
if (!fileExists(path)) { | ||
fs.mkdirSync(path); | ||
} | ||
if (!fileExists(path)) | ||
fs.mkdirSync(path, mode); | ||
} | ||
var mkpath = module.exports.mkpath = function (path, mode) { | ||
path = Path.resolve(path); | ||
if (typeof mode === 'undefined') | ||
mode = 0777 & (~process.umask()); | ||
try { | ||
if (!fs.statSync(path).isDirectory()) { | ||
throw new Error(path + ' exists and is not a directory'); | ||
} | ||
} | ||
catch (error) { | ||
if (error.code === 'ENOENT') { | ||
mkpath(Path.dirname(path), mode); | ||
fs.mkdirSync(path, mode); | ||
} | ||
else { | ||
throw error; | ||
} | ||
} | ||
}; |
module.exports.sprintf = require('sprintf-js').sprintf; | ||
module.exports.extend = require('extend'); | ||
module.exports.isType = require('./src/istype.js').isType; | ||
@@ -6,0 +5,0 @@ module.exports.isArray = require('./src/istype.js').isArray; |
9814
246