Browse files

Changed utilities.fileOrDirectoryExists to use fs.statSync.

  • Loading branch information...
1 parent 691e0f6 commit 5e2b434b7665a712c792e5cb1a993df11495863d @thatismatt committed Jun 11, 2010
Showing with 10 additions and 2 deletions.
  1. +10 −2 lib/josi/utilities.js
View
12 lib/josi/utilities.js
@@ -19,8 +19,16 @@ this.argumentsToArray = function(args) {
}
this.fileOrDirectoryExists = fileOrDirectoryExists = function(fileOrDirectory) {
- return fs.readdirSync(path.dirname(fileOrDirectory))
- .indexOf(path.basename(fileOrDirectory)) != -1;
+ try {
+ fs.statSync(fileOrDirectory);
+ return true;
+ } catch (e) {
+ if (e.errno && e.errno == 2) {
+ return false;
+ } else {
+ throw e;
+ }
+ }
};
this.cwdContainsApp = function() {

0 comments on commit 5e2b434

Please sign in to comment.