Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

enfsmkdirp

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enfsmkdirp - npm Package Compare versions

Comparing version 0.1.0 to 1.0.0

6

CHANGELOG.md

@@ -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

index.js

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

98

lib/mkdirpAsync.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc