
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
Batch create directories or delete them.
I got tired of checking whether a group of directories exist before I create or make them. Even worse, when you have to check three directories:
var fs = require('fs')
, mkdirp = require('mkdirp');
var dirs = ['/tmp/a', '/tmp/b', '/tmp/c'];
var i = 0;
function again(callback) {
if (i < dirs.length) {
fs.exists(dirs[i], function(itDoes) {
if (!itDoes)
fs.mkdir(dirs[i], function(err) {
if (err) {
callback(err); //<--- error return
} else {
i += 1;
again(callback);
}
})
else
i += 1;
again(callback);
});
} else {
callback(); //<--- done
}
}
again(function(err){
if (err)
console.log('We have an error.')
else
console.log('Done.');
});
Yuck.
Why not the following:
var batchdir = require('batchdir');
var dirs = ['/tmp/a', '/tmp/b', '/tmp/c'];
batchdirs(dirs).mkdirs(function(err) {
if (err)
console.log('We have an error.')
else
console.log('Done.');
})
Much cleaner.
npm install batchdir
Contsructor function.
Args:
batchdirs(['d1', 'd2'])
//or
batchdirs('d1', 'd2')
Creates the directory(ies) if they don't exist. Will make full path like mkdir -p.
Args:
Error object if one existed.batchdirs(dirs).create(function(err) { });
Deletes directory(ies) if they do exist. Will delete all of the contents like rm -rf.
Args:
Error object if one existed.batchdirs(dirs).remove(function(err) { });
JP Richardson (@jprichardson) read my coding blog Procbits.
If you use Git with others, you should checkout Gitpilot to make collaboration with Git simple using a different GUI. We would love your feedback.
(MIT License)
Copyright 2012, JP Richardson jprichardson@gmail.com
FAQs
Batch create directories or delete them.
The npm package batchdir receives a total of 1 weekly downloads. As such, batchdir popularity was classified as not popular.
We found that batchdir 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.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.