Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
The mkpath npm package is used to create directories recursively, meaning it can create a directory and any necessary subdirectories in a single call. This is particularly useful for ensuring that a directory structure exists before writing files to it.
Create Nested Directories
This feature allows you to create a nested directory structure in one go. The code sample demonstrates how to create the directories 'path/to/nested/directories' and handle any potential errors.
const mkpath = require('mkpath');
mkpath('path/to/nested/directories', function (err) {
if (err) throw err;
console.log('Directories created');
});
Custom Permissions
This feature allows you to set custom permissions for the directories being created. The code sample shows how to create directories with the permission set to 0755.
const mkpath = require('mkpath');
mkpath('path/to/nested/directories', 0755, function (err) {
if (err) throw err;
console.log('Directories created with custom permissions');
});
The mkdirp package provides similar functionality to mkpath, allowing you to create nested directories recursively. It is widely used and has a simple API. Compared to mkpath, mkdirp is more popular and has more frequent updates.
The fs-extra package extends the native Node.js fs module with additional methods, including a method for creating directories recursively. It offers a broader range of file system utilities compared to mkpath, making it a more versatile choice for file system operations.
The node-mkdir package is another alternative for creating directories recursively. It is lightweight and straightforward, similar to mkpath, but it is less popular and has fewer features compared to fs-extra and mkdirp.
Make all directories in a path, like mkdir -p
.
var mkpath = require('mkpath');
mkpath('red/green/violet', function (err) {
if (err) throw err;
console.log('Directory structure red/green/violet created');
});
mkpath.sync('/tmp/blue/orange', 0700);
Create all directories that don't exist in path
with permissions mode
. When finished, callback(err)
fires with the error, if any.
Synchronous version of the same. Throws error, if any.
This software is released under the MIT license.
FAQs
Make all directories in a path, like mkdir -p
The npm package mkpath receives a total of 215,080 weekly downloads. As such, mkpath popularity was classified as popular.
We found that mkpath demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.