
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Safely wipe a folder.
This is the perfect library for when you want to wipe a folder with user's confirmation.
.DS_Store
or Thumbs.db
as configured with config.ignore
), the
folder will be removed without asking anything.config.force
is set to true
, wipe anyway.Note: This library requires Node.js v8.0.0 or higher as it uses native JavaScript promises and util.promisify
.
You can configure the following variables:
Name | Description | Default |
---|---|---|
stdin , stdout , stderr | Streams to use for I/O. | process.* streams |
ignore | An array of files to ignore when checking if a directory is empty. | .DS_Store and Thumbs.db |
parent | A (supposed) parent directory of the directory to wipe. If the parent is contained in the directory to wipe, the process will be aborted in all cases. | |
interactive | Whether the session is interactive. | true |
force | Whether to force the wipe if the folder is not empty. | false |
silent | The error messages are not printed if this is set to true . | false |
messages | An object of messages for user prompt and error display. |
The messages are:
Name | Description |
---|---|
contained | Error message when the folder to wipe is contained in the configured parent folder. |
confirm | Text to prompt the user to confirm the (not empty) directory wipe. |
abort | Error message when the user refuses to wipe the folder. |
The function is asynchronous and returns a promise. Nothing is passed to
the success function, but you'll get an Error
instance in the error
function. It can have the following code
property:
Code | Description |
---|---|
CONTAINED | Refused to remove the directory since it's containing the supposed parent. |
ABORT | The user aborted the operation (or we're not in an interactive session and config.force is false ). |
var safeWipe = require('safe-wipe');
safeWipe('directory', {
parent: __dirname,
messages: {
abort: 'Nope.',
},
}).then(function () {
console.log('Successfully removed!');
}, function (e) {
console.error(e.message, e.code);
});
var mySafeWipe = safeWipe({
interactive: false,
});
mySafeWipe('some-directory').then(function () {
// ...
});
mySafeWipe('another-directory', {
force: true,
});
[0.3.0] - 2025-03-05
BREAKING
FAQs
> Safely wipe a folder.
The npm package safe-wipe receives a total of 14,528 weekly downloads. As such, safe-wipe popularity was classified as popular.
We found that safe-wipe demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.