diff --git a/lib/db/json.js b/lib/db/json.js index 08bd09d2193c4f8d7e1ee5b0fa379f31eb9baf6d..0bcfbf8a1fa9bcc5fdb8fab56c40705ff1b01e23 100644 --- a/lib/db/json.js +++ b/lib/db/json.js @@ -16,6 +16,13 @@ logger = require('../logging.js').logger, configuration = require('../configuration.js'), temp = require('temp'); +// existsSync moved from path in 0.6.x to fs in 0.8.x +if (typeof fs.existsSync === 'function') { + var existsSync = fs.existsSync; +} else { + var existsSync = path.existsSync; +} + // a little alias for stringify const ESC = JSON.stringify; @@ -59,7 +66,7 @@ function flush() { function sync() { // the database not existing yet just means its empty, don't log an error - if (fs.existsSync(dbPath)) { + if (existsSync(dbPath)) { try { db = JSON.parse(fs.readFileSync(dbPath)); diff --git a/lib/i18n.js b/lib/i18n.js index 08c9ff7a4e6ca29047520839a4b0c7dfdbc3edc7..374c879688adabc933a3466cc9bc168beeeddbf5 100644 --- a/lib/i18n.js +++ b/lib/i18n.js @@ -21,6 +21,13 @@ var logger = require('./logging.js').logger, util = require('util'), fs = require('fs'); +// existsSync moved from path in 0.6.x to fs in 0.8.x +if (typeof fs.existsSync === 'function') { + var existsSync = fs.existsSync; +} else { + var existsSync = path.existsSync; +} + const BIDI_RTL_LANGS = ['ar', 'db-LB', 'fa', 'he']; var mo_cache = {}; @@ -66,8 +73,8 @@ exports.abide = function (options) { default_locale = localeFrom(options.default_lang); mo_cache[l] = { - mo_exists: fs.existsSync(mo_file_path(l)), - json_exists: fs.existsSync(json_file_path(l)), + mo_exists: existsSync(mo_file_path(l)), + json_exists: existsSync(json_file_path(l)), gt: null }; if (l !== debug_locale) { diff --git a/lib/logging.js b/lib/logging.js index 4472cc2484838d443e22ace764d6f8bd1c9d1cf9..a67a01190cb2ca7f311f9718f4a9b453abb38b7a 100644 --- a/lib/logging.js +++ b/lib/logging.js @@ -20,12 +20,19 @@ configuration = require("./configuration"), path = require('path'), fs = require('fs'); +// existsSync moved from path in 0.6.x to fs in 0.8.x +if (typeof fs.existsSync === 'function') { + var existsSync = fs.existsSync; +} else { + var existsSync = path.existsSync; +} + // go through the configuration and determine log location var log_path = path.join(configuration.get('var_path'), 'log'); // simple inline function for creation of dirs function mkdir_p(p) { - if (!fs.existsSync(p)) { + if (!existsSync(p)) { mkdir_p(path.dirname(p)); fs.mkdirSync(p, "0755"); } diff --git a/lib/metrics.js b/lib/metrics.js index 6b3f21b519447a2acd3a04efb9593ef428cbe9e6..c5e2cd2b5105b8b9fa2700f7e1c781b4cb2e8434 100644 --- a/lib/metrics.js +++ b/lib/metrics.js @@ -24,6 +24,13 @@ path = require('path'), fs = require('fs'), urlparse = require('urlparse'); +// existsSync moved from path in 0.6.x to fs in 0.8.x +if (typeof fs.existsSync === 'function') { + var existsSync = fs.existsSync; +} else { + var existsSync = path.existsSync; +} + // go through the configuration and determine log location // for now we only log to one place // FIXME: separate logs depending on purpose? @@ -33,7 +40,7 @@ var LOGGER; // simple inline function for creation of dirs function mkdir_p(p) { - if (!fs.existsSync(p)) { + if (!existsSync(p)) { mkdir_p(path.dirname(p)); fs.mkdirSync(p, "0755"); }