1 path
exports.resolveInclude = function(name, filename, isDir) {var dirname = path.dirname;var extname = path.extname;var resolve = path.resolve;var includePath = resolve(isDir ? filename : dirname(filename), name);var ext = extname(name);if (!ext) {includePath += '.ejs';}return includePath;};
path.dirname : 返回绝对路劲
path.extname: 文件扩展名
path.resolve: 对一系列路劲求绝对路劲,从右向左
2 fs
if (options.filename) {filePath = exports.resolveInclude(path, options.filename);if (fs.existsSync(filePath)) {includePath = filePath;}}
fs.existsSync : Returns true if the path exists, false otherwise.
if (fs.existsSync('/etc/passwd')) {console.log('The file exists.');}
