Comparing version 0.1.0 to 1.0.0
@@ -0,1 +1,7 @@ | ||
1.0.0 / 2017-02-21 | ||
================== | ||
* code improvement | ||
* dependencies upgrade | ||
* major version | ||
0.1.0 / 2016-04-06 | ||
@@ -2,0 +8,0 @@ ================== |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -23,2 +23,44 @@ /** | ||
function mkdirp_(path, options, callback) { | ||
options.fs.mkdir(path, options.mode, (err) => { | ||
if (err) { | ||
if (err.code !== "ENOENT" && err.code !== "EEXIST") { | ||
return options.fs.stat(path, (errStat, stat) => { | ||
return callback((errStat || !stat.isDirectory()) ? err : null, errStat ? null : path); | ||
}); | ||
} else if (err.code === "EEXIST") { | ||
return options.fs.stat(path, (errStat, stat) => { | ||
return callback((errStat || !stat.isDirectory()) ? err : null, errStat ? null : path); | ||
}); | ||
} | ||
} else { | ||
return callback(null, path); | ||
} | ||
//ENOENT | ||
const parent = nodePath.dirname(path); | ||
if (parent === path || /\0/.test(path)) { | ||
return callback(err); | ||
} | ||
if ((/"/.test(path) || /\:\\.*\\.*:.*\\/.test(path)) && isWindows) { | ||
let e = new Error("Invalid character found in path."); | ||
e.code = "EINVALID"; | ||
return callback(e); | ||
} | ||
mkdirp_(parent, options, (errParent) => { | ||
if (errParent) { | ||
return callback(errParent); | ||
} | ||
options.fs.mkdir(path, options.mode, (errPath) => { | ||
//Ignore EEXIST error in asynchronous calls to mkdirp | ||
if (errPath && errPath.code !== "EEXIST") { | ||
return callback(err); | ||
} | ||
callback(null, path); | ||
}); | ||
}); | ||
}); | ||
} | ||
/** | ||
@@ -37,3 +79,2 @@ * Automatically create directories and sub-directories (mkdir -p) | ||
function mkdirp(path, opt, callback) { | ||
let options, paths, callbackCalled, size, umask, cwd, done = []; | ||
@@ -46,11 +87,12 @@ if (typeof opt === "function") { | ||
options = mkdirUtil.getOptions(opt); | ||
paths = mkdirUtil.getPaths(path); | ||
const options = mkdirUtil.getOptions(opt); | ||
const paths = mkdirUtil.getPaths(path); | ||
umask = process.umask(); | ||
const umask = process.umask(); | ||
process.umask(0); | ||
cwd = process.cwd(); | ||
const cwd = process.cwd(); | ||
size = paths.length; | ||
let size = paths.length; | ||
const done = []; | ||
let callbackCalled = false; | ||
paths.some((p) => { | ||
@@ -77,45 +119,3 @@ p = nodePath.resolve(cwd, p); | ||
function mkdirp_(path, options, callback) { | ||
options.fs.mkdir(path, options.mode, (err)=> { | ||
if (err) { | ||
if (err.code !== "ENOENT" && err.code !== "EEXIST") { | ||
return options.fs.stat(path, (errStat, stat) => { | ||
return callback((errStat || !stat.isDirectory()) ? err : null, errStat ? null : path); | ||
}); | ||
} else if (err.code === "EEXIST") { | ||
return options.fs.stat(path, (errStat, stat)=> { | ||
return callback((errStat || !stat.isDirectory()) ? err : null, errStat ? null : path); | ||
}); | ||
} | ||
} else { | ||
return callback(null, path); | ||
} | ||
//ENOENT | ||
const parent = nodePath.dirname(path); | ||
if (parent === path || /\0/.test(path)) { | ||
return callback(err); | ||
} | ||
if ((/"/.test(path) || /\:\\.*\\.*:.*\\/.test(path)) && isWindows) { | ||
let e = new Error("Invalid character found in path."); | ||
e.code = "EINVALID"; | ||
return callback(e); | ||
} | ||
mkdirp_(parent, options, (errParent) => { | ||
if (errParent) { | ||
return callback(errParent); | ||
} | ||
options.fs.mkdir(path, options.mode, (errPath) => { | ||
//Ignore EEXIST error in asynchronous calls to mkdirp | ||
if (errPath && errPath.code !== "EEXIST") { | ||
return callback(err); | ||
} | ||
callback(null, path); | ||
}); | ||
}); | ||
}); | ||
} | ||
module.exports = mkdirp; |
@@ -18,35 +18,5 @@ /** | ||
/** | ||
* Automatically create directories and sub-directories (mkdir -p) | ||
* @param {string|Array} path - the path to the directory | ||
* can be . "/path/to/directory" | ||
* . "/path/{to1,to2}/{dir1,dir2}" | ||
* , ["/path/to/dir1","path/to/dir2"] | ||
* @param {object} opt - various options for list module | ||
* {string|Number} options.mode - the mode to be affected to the directory | ||
* {object} options.fs - the fs module to be used | ||
* @return {Error|string} Error | the last created path | ||
*/ | ||
function mkdirpSync(path, opt) { | ||
let options, paths, done=[]; | ||
options = mkdirUtil.getOptions(opt); | ||
paths = mkdirUtil.getPaths(path); | ||
const umask = process.umask(); | ||
process.umask(0); | ||
try { | ||
while (paths.length) { | ||
done.push(mkdirpSync_(paths.shift(), options)); | ||
} | ||
} finally { | ||
process.umask(umask); | ||
} | ||
done = done.filter(d=>!!d); | ||
return done.length > 1 ? done : done[0]; | ||
} | ||
function mkdirpSync_(path, options) { | ||
let stack = []; | ||
const stack = []; | ||
@@ -96,2 +66,33 @@ stack.push(path); | ||
/** | ||
* Automatically create directories and sub-directories (mkdir -p) | ||
* @param {string|Array} path - the path to the directory | ||
* can be . "/path/to/directory" | ||
* . "/path/{to1,to2}/{dir1,dir2}" | ||
* , ["/path/to/dir1","path/to/dir2"] | ||
* @param {object} opt - various options for list module | ||
* {string|Number} options.mode - the mode to be affected to the directory | ||
* {object} options.fs - the fs module to be used | ||
* @return {Error|string} Error | the last created path | ||
*/ | ||
function mkdirpSync(path, opt) { | ||
let done = []; | ||
const options = mkdirUtil.getOptions(opt); | ||
const paths = mkdirUtil.getPaths(path); | ||
const umask = process.umask(); | ||
process.umask(0); | ||
try { | ||
while (paths.length) { | ||
done.push(mkdirpSync_(paths.shift(), options)); | ||
} | ||
} finally { | ||
process.umask(umask); | ||
} | ||
done = done.filter((d) => !!d); | ||
return done.length > 1 ? done : done[0]; | ||
} | ||
module.exports = mkdirpSync; |
@@ -19,7 +19,10 @@ /** | ||
function inspectCurlyBraces(path) { | ||
return braceExpansion(path); | ||
} | ||
const kindOf = (arg) => arg === null ? "null" : typeof arg === "undefined" ? "undefined" : /^\[object (.*)\]$/.exec(Object.prototype.toString.call(arg))[1].toLowerCase(); | ||
const isObject = (arg) => arg !== null && typeof arg !== "undefined" && "object" === kindOf(arg); | ||
const isString = (arg) => "string" === kindOf(arg); | ||
const inspectCurlyBraces = (path) => braceExpansion(path); | ||
function getOptions(opt) { | ||
@@ -44,6 +47,6 @@ let options = {}; | ||
const path = isArray(originalPath) ? originalPath : [originalPath]; | ||
const path = Array.isArray(originalPath) ? originalPath : [originalPath]; | ||
path.forEach(function(p) { | ||
var ps = [p]; | ||
let ps = [p]; | ||
if (p.indexOf("{")) { | ||
@@ -65,19 +68,6 @@ ps = inspectCurlyBraces(p); | ||
module.exports = { | ||
inspectCurlyBraces: inspectCurlyBraces, | ||
getOptions: getOptions, | ||
getPaths: getPaths | ||
inspectCurlyBraces, | ||
getOptions, | ||
getPaths | ||
}; | ||
function kindOf(arg) { | ||
return arg === null ? "null" : arg === undefined ? "undefined" : /^\[object (.*)\]$/.exec(Object.prototype.toString.call(arg))[1].toLowerCase(); | ||
} | ||
function isObject(arg) { | ||
return arg !== null && arg !== undefined && "object" === kindOf(arg); | ||
} | ||
function isString(arg) { | ||
return "string" === kindOf(arg); | ||
} | ||
function isArray(arg) { | ||
return Array.isArray(arg); | ||
} |
{ | ||
"name": "enfsmkdirp", | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"description": "mkdir -p for node fs module", | ||
@@ -30,12 +30,11 @@ "license": "CC-BY-4.0", | ||
"dependencies": { | ||
"brace-expansion": "1.1.3", | ||
"enfspatch": "0.1" | ||
"brace-expansion": "^1.1.6", | ||
"enfspatch": "^1.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "2.7.0", | ||
"eslint-plugin-mocha": "2.1.0", | ||
"mocha": "2.4.5", | ||
"should": "8.3.0", | ||
"rimraf": "2.5.2", | ||
"mock-fs": "3.8.0" | ||
"eslint": "^3.18.0", | ||
"eslint-plugin-mocha": "^4.9.0", | ||
"mocha": "^3.2.0", | ||
"should": "^11.2.1", | ||
"rimraf": "^2.6.1" | ||
}, | ||
@@ -42,0 +41,0 @@ "keywords": [ |
@@ -0,0 +0,0 @@ [![Build Status](https://travis-ci.org/n3okill/enfsmkdirp.svg)](https://travis-ci.org/n3okill/enfsmkdirp) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
14764
5
1
264
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedclone@2.1.2(transitive)
+ Addedenfsaddins@1.0.1(transitive)
+ Addedenfspatch@1.0.1(transitive)
- Removedbalanced-match@0.3.0(transitive)
- Removedbrace-expansion@1.1.3(transitive)
- Removedclone@1.0.2(transitive)
- Removedenfsaddins@0.1.0(transitive)
- Removedenfspatch@0.1.0(transitive)
Updatedbrace-expansion@^1.1.6
Updatedenfspatch@^1.0