delete-empty递归删除空目录
"delete-empty": "3.0.0"
async-await (promise)
const deleteEmpty = require('delete-empty');
(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/'));

Comments