Browse files

existsSync changes for Node 0.8 compat.

  • Loading branch information...
1 parent 19ea629 commit 0a24dcc9dcd6678b2741436708f8025a84596648 mde committed Jun 27, 2012
Showing with 10 additions and 6 deletions.
  1. +1 −1 lib/api.js
  2. +6 −4 lib/loader.js
  3. +3 −1 lib/task/task.js
View
2 lib/api.js
@@ -192,7 +192,7 @@ var api = new (function () {
@example
task('createTests, function () {
- if (!path.existsSync('./tests')) {
+ if (!fs.existsSync('./tests')) {
fail('Test directory does not exist.');
}
else {
View
10 lib/loader.js
@@ -18,6 +18,8 @@
var path = require('path')
, fs = require('fs')
+ , existsSync = typeof fs.existsSync == 'function' ?
+ fs.existsSync : path.existsSync
, fileUtils = require('./utils/file')
, Loader;
@@ -37,8 +39,8 @@ Loader = function () {
exists = function () {
var cwd = process.cwd();
- if (path.existsSync(jakefile) || path.existsSync(jakefile + '.js') ||
- path.existsSync(jakefile + '.coffee')) {
+ if (existsSync(jakefile) || existsSync(jakefile + '.js') ||
+ existsSync(jakefile + '.coffee')) {
return true;
}
if (!fileSpecified) {
@@ -54,7 +56,7 @@ Loader = function () {
fail('No Jakefile. Specify a valid path with -f/--jakefile, or place one in the current directory.');
}
- isCoffee = path.existsSync(jakefile + '.coffee');
+ isCoffee = existsSync(jakefile + '.coffee');
if (isCoffee) {
CoffeeScript = _requireCoffee();
}
@@ -65,7 +67,7 @@ Loader = function () {
var dirname = d || 'jakelib'
, dirlist;
dirname = fileUtils.absolutize(dirname);
- if (path.existsSync(dirname)) {
+ if (existsSync(dirname)) {
dirlist = fs.readdirSync(dirname);
dirlist.forEach(function (filePath) {
if (JAKEFILE_PAT.test(filePath)) {
View
4 lib/task/task.js
@@ -1,5 +1,7 @@
var fs = require('fs')
, path = require('path')
+ , existsSync = typeof fs.existsSync == 'function' ?
+ fs.existsSync : path.existsSync
, EventEmitter = require('events').EventEmitter
, Task
, TaskBase
@@ -141,7 +143,7 @@ TaskBase = new (function () {
if (!prereq) {
filePath = name.split(':')[1] || name;
// Create a dummy FileTask if file actually exists
- if (path.existsSync(filePath)) {
+ if (existsSync(filePath)) {
stats = fs.statSync(filePath);
prereq = new jake.FileTask(name);
prereq.modTime = stats.mtime;

0 comments on commit 0a24dcc

Please sign in to comment.