Merge pull request #3008 from Gared/directory_check

Fixed path check
This commit is contained in:
John McLear 2016-06-22 21:50:34 +01:00 committed by GitHub
commit 65dcb783d1
3 changed files with 17 additions and 3 deletions

View File

@ -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')
;

View File

@ -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;

View File

@ -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;