🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

mkdir-async-recursive

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mkdir-async-recursive - npm Package Compare versions

Comparing version
1.0.1
to
1.0.2
+10
-20
dist/index.cjs
'use strict';
const fs = require('node:fs');
const nodePath = require('node:path');
const node_fs = require('node:fs');
const node_path = require('node:path');
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
const nodePath__default = /*#__PURE__*/_interopDefaultCompat(nodePath);
const validateUint32 = (value, name) => {

@@ -45,28 +40,23 @@ if (typeof value !== "number") {

}
const sep = path.includes("/") ? "/" : nodePath__default.sep;
const dirs = path.split(sep);
const _sep = path.includes("/") ? "/" : node_path.sep;
const dirs = path.split(_sep);
let dirPath = "";
const result = [];
for (const dir of dirs) {
dirPath += `${dir}${sep}`;
await mkdir(dirPath, mode);
dirPath += `${dir}${_sep}`;
mkdir(dirPath, mode);
}
async function mkdir(path2, mode2) {
if (!fs__default.existsSync(dirPath)) {
function mkdir(path2, mode2) {
if (!node_fs.existsSync(dirPath)) {
try {
fs__default.mkdirSync(path2, mode2);
node_fs.mkdirSync(path2, mode2);
result.push(path2);
return await Promise.resolve(true);
} catch (error) {
console.error(error);
return await Promise.resolve(false);
}
}
return await Promise.resolve(void 0);
}
return await Promise.resolve(
result.length ? nodePath__default.resolve(result[0]) : void 0
);
return result.length ? node_path.resolve(result[0]) : void 0;
}
module.exports = mkdirRecursive;
import { MakeDirectoryOptions } from 'node:fs';
type MakeDirectoryRecursiveOptions = Omit<
MakeDirectoryOptions,
'recursive'
>;
type MakeDirectoryRecursiveOptions = Omit<MakeDirectoryOptions, 'recursive'>;
declare function mkdirRecursive(path: string, options?: string | number | MakeDirectoryRecursiveOptions): Promise<string | undefined>;
export { mkdirRecursive as default };
import { MakeDirectoryOptions } from 'node:fs';
type MakeDirectoryRecursiveOptions = Omit<
MakeDirectoryOptions,
'recursive'
>;
type MakeDirectoryRecursiveOptions = Omit<MakeDirectoryOptions, 'recursive'>;
declare function mkdirRecursive(path: string, options?: string | number | MakeDirectoryRecursiveOptions): Promise<string | undefined>;
export { mkdirRecursive as default };
import { MakeDirectoryOptions } from 'node:fs';
type MakeDirectoryRecursiveOptions = Omit<
MakeDirectoryOptions,
'recursive'
>;
type MakeDirectoryRecursiveOptions = Omit<MakeDirectoryOptions, 'recursive'>;
declare function mkdirRecursive(path: string, options?: string | number | MakeDirectoryRecursiveOptions): Promise<string | undefined>;
export { mkdirRecursive as default };

@@ -1,3 +0,3 @@

import fs from 'node:fs';
import nodePath from 'node:path';
import { existsSync, mkdirSync } from 'node:fs';
import { sep, resolve } from 'node:path';

@@ -38,28 +38,23 @@ const validateUint32 = (value, name) => {

}
const sep = path.includes("/") ? "/" : nodePath.sep;
const dirs = path.split(sep);
const _sep = path.includes("/") ? "/" : sep;
const dirs = path.split(_sep);
let dirPath = "";
const result = [];
for (const dir of dirs) {
dirPath += `${dir}${sep}`;
await mkdir(dirPath, mode);
dirPath += `${dir}${_sep}`;
mkdir(dirPath, mode);
}
async function mkdir(path2, mode2) {
if (!fs.existsSync(dirPath)) {
function mkdir(path2, mode2) {
if (!existsSync(dirPath)) {
try {
fs.mkdirSync(path2, mode2);
mkdirSync(path2, mode2);
result.push(path2);
return await Promise.resolve(true);
} catch (error) {
console.error(error);
return await Promise.resolve(false);
}
}
return await Promise.resolve(void 0);
}
return await Promise.resolve(
result.length ? nodePath.resolve(result[0]) : void 0
);
return result.length ? resolve(result[0]) : void 0;
}
export { mkdirRecursive as default };
{
"name": "mkdir-async-recursive",
"version": "1.0.1",
"version": "1.0.2",
"description": "Asynchronously and recursively creates a directory. Returns undefined or the first directory path created.",

@@ -51,4 +51,4 @@ "type": "module",

"devDependencies": {
"@types/node": "^22.10.0",
"prettier": "^3.4.1",
"@types/node": "^22.10.1",
"prettier": "^3.4.2",
"typescript": "^5.7.2",

@@ -55,0 +55,0 @@ "unbuild": "^2.0.0"