Permalink
Browse files

Ignore files for which stat fails (so it works with Emacs' lock files)

  • Loading branch information...
1 parent 8196354 commit 64a1163b0469680554f3de29401242e73e9ed455 @almost almost committed Jan 23, 2012
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/glob.js
View
@@ -49,9 +49,15 @@ exports.glob = function(pattern, options) {
var filepaths = [];
(function recurse(dirpath, depth) {
fs.readdirSync(dirpath).forEach(function(filepath) {
+ var stat;
// Make relative path absolute.
filepath = path.join(dirpath, filepath);
- if (fs.statSync(filepath).isDirectory()) {
+ try {
+ stat = fs.statSync(filepath);
+ } catch (e) {
+ // Ignore files that can't be "stat"ed (such as emacs's lock files)
+ }
+ if (stat && stat.isDirectory()) {
// If the path is a directory, push it onto the array, adding a
// trailing /.
filepaths.push(filepath + pathSeparator);

0 comments on commit 64a1163

Please sign in to comment.