From 3a7c65a5da4f8484dc9d7ba4e23f0a903205099d Mon Sep 17 00:00:00 2001 From: Weltschmerz Date: Wed, 18 Jul 2012 14:02:06 +0000 Subject: [PATCH] Merge into utils.js --- bin/haraka | 2 +- existsSync.js | 6 ------ outbound.js | 5 ++--- plugins/queue/quarantine.js | 2 +- utils.js | 5 +++++ 5 files changed, 9 insertions(+), 11 deletions(-) delete mode 100644 existsSync.js diff --git a/bin/haraka b/bin/haraka index 8b297d817..777a9fe2b 100755 --- a/bin/haraka +++ b/bin/haraka @@ -34,7 +34,7 @@ var fs = require('fs'), "f": ["--force"], }, parsed = nopt(knownOpts, shortHands, process.argv, 2), - existsSync = require('../existsSync'); + existsSync = require('../utils').existsSync; var usage = [ "\033[32;40mHaraka.js\033[0m — A Node.js Email Server project", diff --git a/existsSync.js b/existsSync.js deleted file mode 100644 index df3626ee5..000000000 --- a/existsSync.js +++ /dev/null @@ -1,6 +0,0 @@ - -var versions = process.version.split('.'); -var version = Number(versions[0].substring(1)); -var subversion = Number(versions[1]); - -module.exports = require((version > 0 || subversion >= 8) ? 'fs' : 'path').existsSync; diff --git a/outbound.js b/outbound.js index 4876287e5..667112215 100644 --- a/outbound.js +++ b/outbound.js @@ -13,8 +13,9 @@ var config = require('./config'); var constants = require('./constants'); var trans = require('./transaction'); var plugins = require('./plugins'); -var date_to_str = require('./utils').date_to_str; var Address = require('./address').Address; +var date_to_str = utils.date_to_str; +var existsSync = utils.existsSync; var core_consts = require('constants'); var WRITE_EXCL = core_consts.O_CREAT | core_consts.O_TRUNC | core_consts.O_WRONLY | core_consts.O_EXCL; @@ -33,8 +34,6 @@ var uniq = Math.round(Math.random() * MAX_UNIQ); var max_concurrency = config.get('outbound.concurrency_max') || 100; var queue_count = 0; -var existsSync = require('./existsSync') - exports.list_queue = function () { this._load_cur_queue("_list_file"); } diff --git a/plugins/queue/quarantine.js b/plugins/queue/quarantine.js index c3170cf4d..47ec4c7f9 100644 --- a/plugins/queue/quarantine.js +++ b/plugins/queue/quarantine.js @@ -3,7 +3,7 @@ var path = require('path'); var fs = require('fs'); -var existsSync = require('../../existsSync'); +var existsSync = require('../../utils').existsSync; exports.register = function () { this.register_hook('queue','quarantine'); diff --git a/utils.js b/utils.js index 703e6e69c..de57bcd2b 100644 --- a/utils.js +++ b/utils.js @@ -114,3 +114,8 @@ exports.encode_qp = function (str) { return broken_lines + str; } +var versions = process.version.split('.'); +, version = Number(versions[0].substring(1)); +, subversion = Number(versions[1]); + +exports.existsSync = require((version > 0 || subversion >= 8) ? 'fs' : 'path').existsSync;