Skip to content

Commit

Permalink
Scaffold: Normalize repository
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Dec 21, 2018
1 parent 18e2b29 commit df82af5
Show file tree
Hide file tree
Showing 14 changed files with 213 additions and 101 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf

[*.md]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "gulp"
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text eol=lf
32 changes: 31 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# Commenting this out is preferred by some people, see
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules
npm-debug.log

# Users Environment Variables
.lock-wscript

# Garbage files
.DS_Store
13 changes: 0 additions & 13 deletions .jshintrc

This file was deleted.

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
sudo: false
language: node_js
node_js:
- "0.10"
- '10'
- '8'
- '6'
- '4'
- '0.12'
- '0.10'
after_script:
- npm run coveralls
37 changes: 18 additions & 19 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
Copyright (c) 2014 Tyler Kellen
The MIT License (MIT)

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
Copyright (c) 2014-2018 Tyler Kellen <tyler@sleekcode.net>, Blaine Bublitz <blaine.bublitz@gmail.com>, and Eric Schoffstall <yo@contra.io>

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
52 changes: 37 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# empty-dir [![Build Status](https://secure.travis-ci.org/js-cli/js-empty-dir.svg?branch=master)](http://travis-ci.org/js-cli/js-empty-dir)
> Check if a directory is empty.
<p align="center">
<a href="http://gulpjs.com">
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
</a>
</p>

[![NPM](https://nodei.co/npm/empty-dir.png)](https://nodei.co/npm/empty-dir/)
# empty-dir

## Install
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Travis Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]

Install with [npm](https://www.npmjs.com/):

```sh
$ npm install --save empty-dir
```
Check if a directory is empty.

## Usage

Expand All @@ -28,10 +27,19 @@ var result = emptyDir.sync('./test/empty');
console.log('Directory is empty:', result);
```

## Filter function
## API

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.
### `emptyDir(paths, [filterFunction], callback)`

Takes a path string or array of path strings and a callback function. Checks if the given paths are empty and passes any `error` and an `isEmpty` flag to the callback. Optionally takes a filter function before the callback to filter out files that cause false positives.

### `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.

```js
var emptyDir = require('empty-dir');
Expand All @@ -52,8 +60,22 @@ var isEmpty = emptyDir.sync('./test/empty', filter);
console.log('Directory is empty:', isEmpty);
```

## Release History
## License

MIT

[downloads-image]: http://img.shields.io/npm/dm/empty-dir.svg
[npm-url]: https://www.npmjs.com/package/empty-dir
[npm-image]: http://img.shields.io/npm/v/empty-dir.svg

[travis-url]: https://travis-ci.org/gulpjs/empty-dir
[travis-image]: http://img.shields.io/travis/gulpjs/empty-dir.svg?label=travis-ci

[appveyor-url]: https://ci.appveyor.com/project/gulpjs/empty-dir
[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/empty-dir.svg?label=appveyor

[coveralls-url]: https://coveralls.io/r/gulpjs/empty-dir
[coveralls-image]: http://img.shields.io/coveralls/gulpjs/empty-dir/master.svg

* 2018-03-09 - v1.0.0 - refactored "isEmpty" logic so that it returns early, as soon as a non-filtered file is encountered, instead of filtering the entire list and comparing against length. Also allows an array to be passed (this avoids having to call `fs.readdir()` multiple times).
* 2016-02-07 - v0.2.0 - add filter support
* 2014-05-08 - v0.1.0 - initial release
[gitter-url]: https://gitter.im/gulpjs/gulp
[gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg
26 changes: 26 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# http://www.appveyor.com/docs/appveyor-yml
# http://www.appveyor.com/docs/lang/nodejs-iojs

environment:
matrix:
# node.js
- nodejs_version: "0.10"
- nodejs_version: "0.12"
- nodejs_version: "4"
- nodejs_version: "6"
- nodejs_version: "8"
- nodejs_version: "10"

install:
- ps: Install-Product node $env:nodejs_version
- npm install

test_script:
- node --version
- npm --version
- cmd: npm test

build: off

# build version format
version: "{build}"
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ function isEmpty(files, filter) {
function isDirectory(filepath) {
try {
return fs.statSync(filepath).isDirectory();
} catch (err) {}
} catch (err) {
// Ignore error
}
return false;
}

Expand Down
47 changes: 30 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,44 @@
{
"name": "empty-dir",
"description": "Check if a directory is empty.",
"version": "1.0.0",
"homepage": "https://github.com/js-cli/js-empty-dir",
"author": "Tyler Kellen <http://goingslowly.com/>",
"repository": "js-cli/js-empty-dir",
"bugs": {
"url": "https://github.com/js-cli/js-empty-dir/issues"
},
"description": "Check if a directory is empty.",
"author": "Gulp Team <team@gulpjs.com> (http://gulpjs.com/)",
"contributors": [
"Tyler Kellen <tyler@sleekcode.net>",
"Jon Schlinkert <jon.schlinkert@sellside.com>",
"Blaine Bublitz <blaine.bublitz@gmail.com>"
],
"repository": "gulpjs/empty-dir",
"license": "MIT",
"engines": {
"node": ">= 0.10"
},
"main": "index.js",
"files": [
"index.js"
"index.js",
"LICENSE"
],
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"test": "mocha"
"lint": "eslint .",
"pretest": "npm run lint",
"test": "mocha --async-only",
"cover": "istanbul cover _mocha --report lcovonly",
"coveralls": "npm run cover && istanbul-coveralls"
},
"dependencies": {},
"devDependencies": {
"eslint": "^2.13.0",
"eslint-config-gulp": "^3.0.1",
"expect": "^1.20.2",
"istanbul": "^0.4.3",
"istanbul-coveralls": "^1.0.3",
"mocha": "^3.5.3"
},
"keywords": [
"empty",
"is-empty",
"directory",
"folder"
],
"devDependencies": {
"mocha": "^3.5.3"
}
"folder",
"check"
]
}
3 changes: 3 additions & 0 deletions test/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "gulp/test"
}

0 comments on commit df82af5

Please sign in to comment.