delete-empty
Advanced tools
Comparing version 0.1.1 to 0.1.2
17
index.js
@@ -13,5 +13,10 @@ /*! | ||
function deleteEmpty(cwd, cb) { | ||
function deleteEmpty(cwd, options, cb) { | ||
if(cb === undefined) { | ||
cb = options; | ||
options = {}; | ||
} | ||
if (utils.emptySync(cwd)) { | ||
utils.del(cwd, function(err) { | ||
utils.del(cwd, options, function(err) { | ||
if (err) return cb(err); | ||
@@ -37,3 +42,3 @@ return cb(null, [cwd]); | ||
utils.del(dir, function(err) { | ||
utils.del(dir, options, function(err) { | ||
if (err) return next(err); | ||
@@ -49,5 +54,5 @@ | ||
deleteEmpty.sync = function(cwd) { | ||
deleteEmpty.sync = function(cwd, options) { | ||
if (utils.emptySync(cwd)) { | ||
utils.del.sync(cwd); | ||
utils.del.sync(cwd, options); | ||
return [cwd]; | ||
@@ -63,3 +68,3 @@ } | ||
if (utils.emptySync(dir)) { | ||
utils.del.sync(dir); | ||
utils.del.sync(dir, options); | ||
res.push(dir); | ||
@@ -66,0 +71,0 @@ } |
{ | ||
"name": "delete-empty", | ||
"version": "0.1.2", | ||
"description": "Recursively delete all empty folders in a directory and child directories.", | ||
"version": "0.1.1", | ||
"homepage": "https://github.com/jonschlinkert/delete-empty", | ||
@@ -25,8 +25,9 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"async": "^1.5.0", | ||
"delete": "^0.2.1", | ||
"lazy-cache": "^0.2.4", | ||
"matched": "^0.3.2" | ||
"delete": "^0.3.0", | ||
"lazy-cache": "^1.0.3", | ||
"matched": "^0.4.1" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*" | ||
"gulp-format-md": "^0.1.7", | ||
"mocha": "^2.4.5" | ||
}, | ||
@@ -46,11 +47,26 @@ "keywords": [ | ||
"verb": { | ||
"run": true, | ||
"toc": false, | ||
"layout": "default", | ||
"tasks": [ | ||
"readme" | ||
], | ||
"reflinks": [ | ||
"verb" | ||
], | ||
"plugins": [ | ||
"gulp-format-md" | ||
], | ||
"related": { | ||
"list": [ | ||
"copy", | ||
"delete", | ||
"matched", | ||
"copy", | ||
"fs-utils" | ||
"fs-utils", | ||
"matched" | ||
] | ||
}, | ||
"lint": { | ||
"reflinks": true | ||
} | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# delete-empty [![NPM version](https://badge.fury.io/js/delete-empty.svg)](http://badge.fury.io/js/delete-empty) | ||
# delete-empty [![NPM version](https://img.shields.io/npm/v/delete-empty.svg?style=flat)](https://www.npmjs.com/package/delete-empty) [![NPM downloads](https://img.shields.io/npm/dm/delete-empty.svg?style=flat)](https://npmjs.org/package/delete-empty) [![Build Status](https://img.shields.io/travis/jonschlinkert/delete-empty.svg?style=flat)](https://travis-ci.org/jonschlinkert/delete-empty) | ||
@@ -7,6 +7,6 @@ > Recursively delete all empty folders in a directory and child directories. | ||
Install with [npm](https://www.npmjs.com/) | ||
Install with [npm](https://www.npmjs.com/): | ||
```sh | ||
$ npm i delete-empty --save | ||
$ npm install delete-empty --save | ||
``` | ||
@@ -22,3 +22,3 @@ | ||
Given the directory structure, the **highlighted directories** would be deleted. | ||
Given the following directory structure, the **highlighted directories** would be deleted. | ||
@@ -63,2 +63,4 @@ ```diff | ||
You might also be interested in these projects: | ||
* [copy](https://www.npmjs.com/package/copy): Copy files or directories using globs. | [homepage](https://github.com/jonschlinkert/copy) | ||
@@ -69,2 +71,20 @@ * [delete](https://www.npmjs.com/package/delete): Delete files and folders and any intermediate directories if they exist (sync and async). | [homepage](https://github.com/jonschlinkert/delete) | ||
## Contributing | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/delete-empty/issues/new). | ||
## Building docs | ||
Generate readme and API documentation with [verb](https://github.com/verbose/verb): | ||
```sh | ||
$ npm install verb && npm run docs | ||
``` | ||
Or, if [verb](https://github.com/verbose/verb) is installed globally: | ||
```sh | ||
$ verb | ||
``` | ||
## Running tests | ||
@@ -75,9 +95,5 @@ | ||
```sh | ||
$ npm i -d && npm test | ||
$ npm install -d && npm test | ||
``` | ||
## Contributing | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/delete-empty/issues/new). | ||
## Author | ||
@@ -87,12 +103,12 @@ | ||
+ [github/jonschlinkert](https://github.com/jonschlinkert) | ||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
* [github/jonschlinkert](https://github.com/jonschlinkert) | ||
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
## License | ||
Copyright © 2015 Jon Schlinkert | ||
Released under the MIT license. | ||
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
Released under the [MIT license](https://github.com/jonschlinkert/delete-empty/blob/master/LICENSE). | ||
*** | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on December 03, 2015._ | ||
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on March 24, 2016._ |
30
utils.js
'use strict'; | ||
var fs = require('fs'); | ||
/** | ||
* Module dependencies | ||
*/ | ||
var utils = require('lazy-cache')(require); | ||
/** | ||
* Temporarily re-assign `require` to trick browserify and | ||
* webpack into reconizing lazy dependencies. | ||
* | ||
* This tiny bit of ugliness has the huge dual advantage of | ||
* only loading modules that are actually called at some | ||
* point in the lifecycle of the application, whilst also | ||
* allowing browserify and webpack to find modules that | ||
* are depended on but never actually called. | ||
*/ | ||
var fn = require; | ||
@@ -26,3 +9,3 @@ require = utils; | ||
/** | ||
* Lazily required module dependencies | ||
* Module dependencies | ||
*/ | ||
@@ -33,7 +16,2 @@ | ||
require('matched', 'glob'); | ||
/** | ||
* Restore `require` | ||
*/ | ||
require = fn; | ||
@@ -44,3 +22,3 @@ | ||
return fs.readdirSync(dir); | ||
} catch(err) {} | ||
} catch (err) {} | ||
return []; | ||
@@ -50,3 +28,3 @@ } | ||
utils.empty = function(dir, cb) { | ||
fs.readdir(dir, function (err, files) { | ||
fs.readdir(dir, function(err, files) { | ||
if (err) { | ||
@@ -64,3 +42,3 @@ // if it doesn't exist, we don't | ||
utils.emptySync = function (dir) { | ||
utils.emptySync = function(dir) { | ||
try { | ||
@@ -67,0 +45,0 @@ var files = tryReaddir(dir); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8037
108
2
109
+ Addedarr-union@3.1.0(transitive)
+ Addedasync-array-reduce@0.2.1(transitive)
+ Addedbluebird@3.7.2(transitive)
+ Addeddelete@0.3.2(transitive)
+ Addedfs-exists-sync@0.1.0(transitive)
+ Addedhas-glob@0.1.1(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-extglob@1.0.0(transitive)
+ Addedis-glob@2.0.1(transitive)
+ Addedkind-of@3.2.2(transitive)
+ Addedlazy-cache@1.0.42.0.2(transitive)
+ Addedmatched@0.4.4(transitive)
+ Addedset-getter@0.1.1(transitive)
+ Addedto-object-path@0.3.0(transitive)
- Removedansi-wrap@0.1.0(transitive)
- Removedansi-yellow@0.1.1(transitive)
- Removedasync-array-reduce@0.1.0(transitive)
- Removedbluebird@2.11.0(transitive)
- Removeddelete@0.2.1(transitive)
- Removedglob@5.0.15(transitive)
- Removedlazy-cache@0.1.00.2.7(transitive)
- Removedmatched@0.3.2(transitive)
Updateddelete@^0.3.0
Updatedlazy-cache@^1.0.3
Updatedmatched@^0.4.1