Skip to content

Latest commit

 

History

History
82 lines (59 loc) · 1.78 KB

.verb.md

File metadata and controls

82 lines (59 loc) · 1.78 KB

Usage

const deleteEmpty = require('{%= name %}');

API

Given the following directory structure, the highlighted directories would be deleted.

foo/
└─┬ a/
-  ├── aa/
  ├── bb/
  │ └─┬ bbb/
  │ │ ├── one.txt
  │ │ └── two.txt
-  ├── cc/
-  ├ b/
-  └ c/

async-await (promise)

If no callback is passed, a promise is returned. Returns the array of deleted directories.

(async () => {
  let deleted = await deleteEmpty('foo');
  console.log(deleted); //=> ['foo/aa/', 'foo/a/cc/', 'foo/b/', 'foo/c/']
})();

// or
deleteEmpty('foo/')
  .then(deleted => console.log(deleted)) //=> ['foo/aa/', 'foo/a/cc/', 'foo/b/', 'foo/c/']
  .catch(console.error);

async callback

Returns the array of deleted directories in the callback.

deleteEmpty('foo/', (err, deleted) => {
  console.log(deleted); //=> ['foo/aa/', 'foo/a/cc/', 'foo/b/', 'foo/c/']
});

sync

Returns the array of deleted directories.

console.log(deleteEmpty.sync('foo/')); //=> ['foo/aa/', 'foo/a/cc/', 'foo/b/', 'foo/c/']

CLI

To use the delete-empty command from any directory you must first install the package globally with the following command:

$ npm install --global delete-empty

Usage

Usage: $ delete-empty <directory> [options]

Directory: (optional) Initial directory to begin the search for empty
           directories. Otherwise, cwd is used.

[Options]:
  -c, --cwd           Set the current working directory for folders to search.
  -d, --dryRun        Do a dry run without deleting any files.
  -h, --help          Display this help menu
  -V, --version       Display the current version of rename
  -v, --verbose       Display all verbose logging messages (currently not used)