代码拉取完成,页面将自动刷新
/*!
* is-directory <https://github.com/jonschlinkert/is-directory>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
var fs = require('fs');
/**
* async
*/
function isDirectory(filepath, cb) {
if (typeof cb !== 'function') {
throw new Error('expected a callback function');
}
if (typeof filepath !== 'string') {
cb(new Error('expected filepath to be a string'));
return;
}
fs.stat(filepath, function(err, stats) {
if (err) {
if (err.code === 'ENOENT') {
cb(null, false);
return;
}
cb(err);
return;
}
cb(null, stats.isDirectory());
});
}
/**
* sync
*/
isDirectory.sync = function isDirectorySync(filepath) {
if (typeof filepath !== 'string') {
throw new Error('expected filepath to be a string');
}
try {
var stat = fs.statSync(filepath);
return stat.isDirectory();
} catch (err) {
if (err.code === 'ENOENT') {
return false;
} else {
throw err;
}
}
return false;
};
/**
* Expose `isDirectory`
*/
module.exports = isDirectory;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。