Comparing version 0.2.2 to 0.2.4
@@ -127,6 +127,22 @@ #!/usr/bin/env node | ||
var exists = node_fs.existsSync ? | ||
function (file) { | ||
return node_fs.existsSync(file); | ||
} : | ||
// if node -v <= 0.6, there's no fs.existsSync method. | ||
function (file) { | ||
try { | ||
node_fs.statSync(file); | ||
return true; | ||
} catch(e) { | ||
return false; | ||
} | ||
}; | ||
// @returns {boolean} true if the file path exists. | ||
sync.exists = function() { | ||
var filepath = node_path.join.apply(node_path, arguments); | ||
return node_fs.existsSync(filepath); | ||
return exists(filepath); | ||
}; | ||
@@ -138,3 +154,3 @@ | ||
var filepath = node_path.join.apply(node_path, arguments); | ||
return node_fs.existsSync(filepath) && node_fs.lstatSync(filepath).isSymbolicLink(); | ||
return exists(filepath) && node_fs.lstatSync(filepath).isSymbolicLink(); | ||
}; | ||
@@ -145,3 +161,3 @@ | ||
var filepath = node_path.join.apply(node_path, arguments); | ||
return node_fs.existsSync(filepath) && node_fs.statSync(filepath).isDirectory(); | ||
return exists(filepath) && node_fs.statSync(filepath).isDirectory(); | ||
}; | ||
@@ -152,3 +168,3 @@ | ||
var filepath = node_path.join.apply(node_path, arguments); | ||
return node_fs.existsSync(filepath) && node_fs.statSync(filepath).isFile(); | ||
return exists(filepath) && node_fs.statSync(filepath).isFile(); | ||
}; | ||
@@ -155,0 +171,0 @@ |
@@ -0,5 +1,21 @@ | ||
var exists = node_fs.existsSync ? | ||
function (file) { | ||
return node_fs.existsSync(file); | ||
} : | ||
// if node -v <= 0.6, there's no fs.existsSync method. | ||
function (file) { | ||
try { | ||
node_fs.statSync(file); | ||
return true; | ||
} catch(e) { | ||
return false; | ||
} | ||
}; | ||
// @returns {boolean} true if the file path exists. | ||
sync.exists = function() { | ||
var filepath = node_path.join.apply(node_path, arguments); | ||
return node_fs.existsSync(filepath); | ||
return exists(filepath); | ||
}; | ||
@@ -11,3 +27,3 @@ | ||
var filepath = node_path.join.apply(node_path, arguments); | ||
return node_fs.existsSync(filepath) && node_fs.lstatSync(filepath).isSymbolicLink(); | ||
return exists(filepath) && node_fs.lstatSync(filepath).isSymbolicLink(); | ||
}; | ||
@@ -18,3 +34,3 @@ | ||
var filepath = node_path.join.apply(node_path, arguments); | ||
return node_fs.existsSync(filepath) && node_fs.statSync(filepath).isDirectory(); | ||
return exists(filepath) && node_fs.statSync(filepath).isDirectory(); | ||
}; | ||
@@ -25,3 +41,3 @@ | ||
var filepath = node_path.join.apply(node_path, arguments); | ||
return node_fs.existsSync(filepath) && node_fs.statSync(filepath).isFile(); | ||
return exists(filepath) && node_fs.statSync(filepath).isFile(); | ||
}; | ||
@@ -28,0 +44,0 @@ |
{ | ||
"name": "fs-sync", | ||
"version": "0.2.2", | ||
"version": "0.2.4", | ||
"description": "synchronous fs with more fun", | ||
@@ -13,4 +13,7 @@ "main": "dist/index", | ||
"type": "git", | ||
"url": "git://github.com/kaelzhang/fs-sync.git" | ||
"url": "git@github.com:kaelzhang/node-fs-sync.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/kaelzhang/node-fs-sync/issues" | ||
}, | ||
"keywords": [ | ||
@@ -17,0 +20,0 @@ "fs", |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
18875
387
1