mirror of
https://github.com/wu736139669/Monkey-Test.git
synced 2026-10-12 20:36:13 +00:00
26 lines
456 B
JavaScript
26 lines
456 B
JavaScript
var fs = require('fs');
|
|
/**
|
|
* Check if file exists and return the result in cache
|
|
*
|
|
* @example
|
|
* var exists = require('./helpers/fsExists')({});
|
|
* exists('.babelrc'); // false
|
|
*/
|
|
module.exports = function(cache) {
|
|
'use strict';
|
|
|
|
cache = cache || {};
|
|
|
|
return function(filename) {
|
|
var cached = cache[filename];
|
|
|
|
if (cached) {
|
|
return cached;
|
|
}
|
|
|
|
cache[filename] = fs.existsSync(filename);
|
|
|
|
return cache[filename];
|
|
};
|
|
};
|