2 * is-directory <https://github.com/jonschlinkert/is-directory>
4 * Copyright (c) 2014-2015, Jon Schlinkert.
5 * Licensed under the MIT License.
10 var fs = require('fs');
16 function isDirectory(filepath, cb) {
17 if (typeof cb !== 'function') {
18 throw new Error('expected a callback function');
21 if (typeof filepath !== 'string') {
22 cb(new Error('expected filepath to be a string'));
26 fs.stat(filepath, function(err, stats) {
28 if (err.code === 'ENOENT') {
35 cb(null, stats.isDirectory());
43 isDirectory.sync = function isDirectorySync(filepath) {
44 if (typeof filepath !== 'string') {
45 throw new Error('expected filepath to be a string');
49 var stat = fs.statSync(filepath);
50 return stat.isDirectory();
52 if (err.code === 'ENOENT') {
62 * Expose `isDirectory`
65 module.exports = isDirectory;