Skip to content

Commit

Permalink
Use fs.existsSync when appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
wltsmrz committed Jul 18, 2012
1 parent 7f45713 commit 31c84df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion bin/haraka
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ var fs = require('fs'),
},
parsed = nopt(knownOpts, shortHands, process.argv, 2);

var subversion = Number(process.version.split('.')[1])
var existsSync = (subversion >= 8 ? fs : path).existsSync

var usage = [
"\033[32;40mHaraka.js\033[0m — A Node.js Email Server project",
Expand Down Expand Up @@ -236,7 +238,7 @@ var plugin_doc = [

function createFile(filePath, data, info) {
try {
if (path.existsSync(filePath) && !parsed.force) {
if (existsSync(filePath) && !parsed.force) {
throw filePath + " already exists";
}
var fd = fs.openSync(filePath, 'w');
Expand Down
5 changes: 4 additions & 1 deletion outbound.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ var uniq = Math.round(Math.random() * MAX_UNIQ);
var max_concurrency = config.get('outbound.concurrency_max') || 100;
var queue_count = 0;

var subversion = Number(process.version.split('.')[1])
var existsSync = (subversion >= 8 ? fs : path).existsSync

exports.list_queue = function () {
this._load_cur_queue("_list_file");
}
Expand All @@ -49,7 +52,7 @@ exports.load_queue = function () {
// properly.

// no reason not to do this stuff syncronously - we're just loading here
if (!path.existsSync(queue_dir)) {
if (!existsSync(queue_dir)) {
this.logdebug("Creating queue directory " + queue_dir);
try {
fs.mkdirSync(queue_dir, 493); // 493 == 0755
Expand Down

0 comments on commit 31c84df

Please sign in to comment.