Socket
Socket
Sign inDemoInstall

clear-dir

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clear-dir

For quickly emptying a directory


Version published
Maintainers
1
Created
Source

clear-dir

For quickly emptying a directory. Good for clearing out dist before rebuilding.

NPM version Build Status Dependency Status

how it works

This package is for when you just want a directory to be empty as soon as possible.

First it moves all the directory's children into a temp directory (adjacent to the original directory) – this is a fast, non-recursive operation. Then it calls your callback. Then it spawns a new process to recursively delete the temp directory in the background. Finally it calls your second callback, if provided.

usage

var clearDir = require('clear-dir');

clearDir(dir, clearedCallback, finalCallback);
  • dir – the directory to empty
  • clearedCallback – function to be run when the contents have been cleared out of the directory
  • finalCallback (optional) – function to be run when the contents have been deleted from the temp location

If the dir doesn't exist, it will be created (and then both your callbacks fired). This might sound weird, but the point of clearDest is to guarantee an empty folder that you can use immediately, so that's what it does.

license

The MIT License

FAQs

Package last updated on 29 Sep 2014

Did you know?

Socket

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.

Install

Related posts

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