Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

empty-dir

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

empty-dir

Check if a directory is empty.

  • 0.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
26K
decreased by-59.91%
Maintainers
2
Weekly downloads
 
Created
Source

empty-dir Build Status

Check if a directory is empty.

NPM

Note that directories with .DS_Store on mac are considered empty.

Example

const emptyDir = require('empty-dir');

emptyDir('./', function (err, result) {
  if (err) {
    console.error(err);
  } else {
    console.log('Directory is empty:', result);
  }
});

var result = emptyDir.sync('./test/empty');
console.log('Directory is empty:', result);

Filter function

Both async and sync take a filter function as the second argument.

(This gives you the ability to eliminate files like .DS_Store on mac, or Thumbs.db on windows from causing the result to be "not empty" (.DS_Store is already filtered by default).)

const emptyDir = require('empty-dir');

function filter(filepath) {
  return !/Thumbs\.db$/i.test(filepath);
}

emptyDir('./', filter, function (err, result) {
  if (err) {
    console.error(err);
  } else {
    console.log('Directory is empty:', result);
  }
});

var result = emptyDir.sync('./test/empty', filter);
console.log('Directory is empty:', result);

Release History

  • 2014-05-08 - v0.1.0 - initial release
  • 2016-02-07 - v0.2.0 - add filter support

Keywords

FAQs

Package last updated on 29 Jul 2016

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