diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/node/hooks/i18n.js | 2 | ||||
-rw-r--r-- | src/node/utils/caching_middleware.js | 3 | ||||
-rw-r--r-- | src/node/utils/path_exists.js | 15 |
3 files changed, 17 insertions, 3 deletions
diff --git a/src/node/hooks/i18n.js b/src/node/hooks/i18n.js index d0be2d6f..1b5b354d 100644 --- a/src/node/hooks/i18n.js +++ b/src/node/hooks/i18n.js @@ -5,7 +5,7 @@ var languages = require('languages4translatewiki') , npm = require('npm') , plugins = require('ep_etherpad-lite/static/js/pluginfw/plugins.js').plugins , semver = require('semver') - , existsSync = fs.statSync || fs.existsSync || path.existsSync + , existsSync = require('../utils/path_exists') ; diff --git a/src/node/utils/caching_middleware.js b/src/node/utils/caching_middleware.js index 91b8143b..65fe5d2f 100644 --- a/src/node/utils/caching_middleware.js +++ b/src/node/utils/caching_middleware.js @@ -21,8 +21,7 @@ var path = require('path'); var zlib = require('zlib'); var settings = require('./Settings'); var semver = require('semver'); - -var existsSync = fs.statSync || fs.existsSync || path.existsSync; +var existsSync = require('./path_exists'); var CACHE_DIR = path.normalize(path.join(settings.root, 'var/')); CACHE_DIR = existsSync(CACHE_DIR) ? CACHE_DIR : undefined; diff --git a/src/node/utils/path_exists.js b/src/node/utils/path_exists.js new file mode 100644 index 00000000..c2d43f6c --- /dev/null +++ b/src/node/utils/path_exists.js @@ -0,0 +1,15 @@ +var fs = require('fs'); + +var check = function(path) { + var existsSync = fs.statSync || fs.existsSync || path.existsSync; + + var result; + try { + result = existsSync(path); + } catch (e) { + result = false; + } + return result; +} + +module.exports = check; |