Comparing version 0.0.8 to 0.0.9
{ | ||
"name": "walkdir", | ||
"description": "Find files simply. Walks a directory tree emitting events based on what it finds. Presents a familliar callback/emitter/a+sync interface. Walk a tree of any depth.", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"author": "Ryan Day <soldair@gmail.com>", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -140,2 +140,15 @@ [![Build Status](https://secure.travis-ci.org/soldair/node-walkdir.png)](http://travis-ci.org/soldair/node-walkdir) | ||
### ignore(path or array of paths) | ||
will not traverse these directories. may be called in the path event handler to ignore dynamically. | ||
```js | ||
var walk = require('walkdir'); | ||
var p = require('path'); | ||
walk('/',function(path,stat){ | ||
// ignore all .git directories. | ||
if(p.basename(path) === '.git') { | ||
this.ignore(path) | ||
} | ||
}) | ||
``` | ||
### cancel a walk in progress | ||
@@ -142,0 +155,0 @@ ```js |
@@ -28,2 +28,3 @@ var EventEmitter = require('events').EventEmitter, | ||
var emitter = new EventEmitter(), | ||
dontTraverse = [], | ||
allPaths = (options.return_object?{}:[]), | ||
@@ -50,2 +51,8 @@ resolved = false, | ||
emitter.ignore = function(path){ | ||
if(Array.isArray(path)) dontTraverse.push.apply(dontTraverse,path) | ||
else dontTraverse.push(path) | ||
return this | ||
} | ||
//mapping is stat functions to event names. | ||
@@ -115,2 +122,11 @@ var statIs = [['isFile','file'],['isDirectory','directory'],['isSymbolicLink','link'],['isSocket','socket'],['isFIFO','fifo'],['isBlockDevice','blockdevice'],['isCharacterDevice','characterdevice']]; | ||
if(dontTraverse.length){ | ||
for(var i=0;i<dontTraverse.length;++i){ | ||
if(dontTraverse[i] == path) { | ||
dontTraverse.splice(i,1) | ||
return; | ||
} | ||
} | ||
} | ||
job(1); | ||
@@ -138,2 +154,3 @@ var readdirAction = function(err,files) { | ||
//use same pattern for sync as async api | ||
@@ -140,0 +157,0 @@ if(options.sync) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24246
35
584
174