Permalink
Browse files

[minor][api] Support node 0.4 - 0.8

  • Loading branch information...
1 parent 52868d5 commit 3700cf1c868622c1da64ea8bbac09ff74ea071d5 @3rd-Eden 3rd-Eden committed Jan 2, 2013
Showing with 14 additions and 4 deletions.
  1. +1 −0 .travis.yml
  2. +13 −4 lib/kju.js
View
@@ -1,5 +1,6 @@
language: node_js
node_js:
+ - 0.4
- 0.6
- 0.8
View
@@ -10,7 +10,16 @@
* Module dependencies
*/
var EventEmitter2 = require('eventemitter2').EventEmitter2
- , fs = require('fs');
+ , fs = require('fs')
+ , path = require('path');
+
+/**
+ * Check the location of `path.exists` as it has been moved to `fs.exists` in
+ * Node 0.8. Check the `fs` module first as `path.exists` contains a deprication
+ * function that spams bullshit
+ */
+var fsExists = fs.exists || path.exists
+ , fsExistsSync = fs.existsSync || path.existsSync;
/**
* Initialize our queue.
@@ -74,7 +83,7 @@ function KJU(configuration) {
if (this.enabled) this.enable();
// make sure our backup path exists
- fs.exists(this.path, function existing(exists) {
+ fsExists(this.path, function existing(exists) {
if (!exists) {
return self.emit('error', new Error(self.path + ' does not exist.'));
}
@@ -267,7 +276,7 @@ KJU.prototype.metrics = function metrics() {
* @api private
*/
KJU.prototype.backup = function backup() {
- if (!this.recover || !this.length || !fs.existsSync(this.path)) return;
+ if (!this.recover || !this.length || !fsExistsSync(this.path)) return;
var filename = /(\d+)\.kju$/
, data = JSON.stringify(this.buffer)
@@ -379,7 +388,7 @@ KJU.prototype.recovery = function recover() {
}
// check if the path exists and if there are files to filter
- fs.exists(this.path, function existsPath(exists) {
+ fsExists(this.path, function existsPath(exists) {
if (!exists) return;
fs.readdir(self.path, filter);

0 comments on commit 3700cf1

Please sign in to comment.