All Projects → gulpjs → empty-dir

gulpjs / empty-dir

Licence: MIT license
Check if a directory is empty.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to empty-dir

delete-empty
Recursively delete all empty folders in a directory and child directories.
Stars: ✭ 38 (+100%)
Mutual labels:  directory, empty
directory-structure
📦 Print a directory tree structure in your Python code.
Stars: ✭ 40 (+110.53%)
Mutual labels:  directory, folder
Voila
Voila is a domain-specific language launched through CLI tool for operating with files and directories in massive amounts in a fast & reliable way.
Stars: ✭ 78 (+310.53%)
Mutual labels:  directory, folder
Cryptolist
Curated collection of blockchain & cryptocurrency resources.
Stars: ✭ 3,501 (+18326.32%)
Mutual labels:  directory, folder
AttackingAD
This repo will contain slides and information from the Attacking Active Directory Hacking Series talks presented at SecKC.
Stars: ✭ 32 (+68.42%)
Mutual labels:  directory
nagitheus
Nagios Check towards Prometheus
Stars: ✭ 19 (+0%)
Mutual labels:  check
noop-cli
◻️ Supreme nothingness
Stars: ✭ 30 (+57.89%)
Mutual labels:  empty
checkif.js
Javascript check library
Stars: ✭ 30 (+57.89%)
Mutual labels:  check
adam
Addon which enhances all user profiles of confluence. It also adds an advanced people directory. The whole addon is configurable by means of an XML, can be localized, supports Velocity templates and supports view and edit restrictions.
Stars: ✭ 12 (-36.84%)
Mutual labels:  directory
kn
Alternative to cd. Navigate by typing abbreviations of paths.
Stars: ✭ 68 (+257.89%)
Mutual labels:  directory
HDEmptyView
一个Swift语言封装的EmptyView显示库,可作用于WKWebView、UITableView、UICollectionView 无网络提醒或者空数据提醒
Stars: ✭ 29 (+52.63%)
Mutual labels:  empty
diffido
Watch web pages for changes
Stars: ✭ 19 (+0%)
Mutual labels:  check
ios-empty-application-xcode-template
🙈 An empty iOS application project template without a storyboard for Xcode 11.
Stars: ✭ 28 (+47.37%)
Mutual labels:  empty
omit-empty
Recursively omit empty properties from an object. Omits empty objects, arrays, strings, and optionally zero. Similar results to what you would expect with `compact` for arrays.
Stars: ✭ 71 (+273.68%)
Mutual labels:  empty
z.vim
Help jumping to the most used directories in vim.
Stars: ✭ 19 (+0%)
Mutual labels:  folder
folder-auth-plugin
Authorization Plugin for Jenkins that works on folders
Stars: ✭ 21 (+10.53%)
Mutual labels:  folder
hexo-directory-category
Automatically add category to Hexo article according to the article file directory.
Stars: ✭ 35 (+84.21%)
Mutual labels:  directory
es-feature-detection
ECMAScript feature and API detection
Stars: ✭ 16 (-15.79%)
Mutual labels:  check
can-npm-publish
A command line tool that check to see if `npm publish` is possible.
Stars: ✭ 61 (+221.05%)
Mutual labels:  check
shallow-equal-object
Shallow equal check object that support TypeScript.
Stars: ✭ 21 (+10.53%)
Mutual labels:  check

empty-dir

NPM version Downloads Build Status Coveralls Status

Check if a directory is empty.

Usage

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

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

// Using a Promise
emptyDir('./').then(function (result) {
  console.log('Directory is empty:', result);
});

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

API

emptyDir(paths, [filterFunction], [callback])

Takes a path string or array of path strings and returns a Promise. Checks if the given paths are empty and resolves with a boolean indicating if the paths are empty directories. Optionally takes a filter function to filter out files that cause false positives. Also, can take a node-style callback function instead of returning a Promise.

emptyDir.sync(paths, [filterFunction])

Same as the above API but operates and returns synchronously. An error will be thrown.

Filter function

Both async and sync take a filter function as the second argument, to ignore files like .DS_Store on mac or Thumbs.db on windows from causing false-negatives.

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

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

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

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

Promises

Global promises are required for this module. If you are using a platform that doesn't have promise support, you'll need to polyfill Promise on the global.

global.Promise = require('insert-your-promise-polyfill-here');

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

emptyDir('./').then(function (result) {
  console.log('Directory is empty:', result);
});

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].