is-directory
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -1,4 +0,1 @@ | ||
--- | ||
tags: ['verb-tag-jscomments'] | ||
--- | ||
# {%= name %} {%= badge("fury") %} | ||
@@ -11,2 +8,8 @@ | ||
## Run tests | ||
```bash | ||
npm test | ||
``` | ||
## Usage | ||
@@ -20,2 +23,9 @@ | ||
//=> 'true' | ||
function isFile(filepath) { | ||
return !isDir(filepath); | ||
} | ||
console.log(isFile('README.md')); | ||
//=> true | ||
``` | ||
@@ -22,0 +32,0 @@ |
30
index.js
@@ -5,11 +5,25 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var isDir = function isDir(filepath, callback) { | ||
if(!callback) { | ||
return isDir.sync(filepath); | ||
} | ||
module.exports = function isDir() { | ||
var filepath = path.join.apply(path, arguments); | ||
if (fs.existsSync(filepath)) { | ||
return fs.statSync(filepath).isDirectory(); | ||
} | ||
return false; | ||
}; | ||
fs.stat(filepath, function(err, stats){ | ||
if(err) { | ||
callback(err); | ||
return; | ||
} | ||
callback(null, stats.isDirectory()); | ||
return; | ||
}); | ||
}; | ||
isDir.sync = function isDirSync(filepath) { | ||
var stat = fs.statSync(filepath); | ||
return stat && stat.isDirectory(); | ||
}; | ||
module.exports = isDir; |
{ | ||
"name": "is-directory", | ||
"description": "Extends `stats.isDirectory()`, returns `true` if a filepath is a directory.", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/jonschlinkert/is-directory", | ||
@@ -24,11 +24,16 @@ "author": { | ||
"keywords": [ | ||
"dir", | ||
"directories", | ||
"directory", | ||
"dirs", | ||
"file", | ||
"filepath", | ||
"files", | ||
"fp", | ||
"fs", | ||
"node", | ||
"node.js", | ||
"path", | ||
"fs", | ||
"file", | ||
"system", | ||
"filepath", | ||
"dir", | ||
"directory" | ||
"paths", | ||
"system" | ||
], | ||
@@ -44,5 +49,4 @@ "main": "index.js", | ||
"verb": ">= 0.2.6", | ||
"chai": ">= 1.9.1", | ||
"mocha": "*" | ||
} | ||
} | ||
} |
@@ -12,2 +12,8 @@ # is-directory [![NPM version](https://badge.fury.io/js/is-directory.png)](http://badge.fury.io/js/is-directory) | ||
## Run tests | ||
```bash | ||
npm test | ||
``` | ||
## Usage | ||
@@ -21,2 +27,9 @@ | ||
//=> 'true' | ||
function isFile(filepath) { | ||
return !isDir(filepath); | ||
} | ||
console.log(isFile('README.md')); | ||
//=> true | ||
``` | ||
@@ -37,2 +50,2 @@ | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on July 19, 2014._ | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 05, 2014._ |
5924
2
47
48
9