Permalink
Browse files

test cases init, .gitignore

Signed-off-by: Nick Jonas <njonas45@gmail.com>
  • Loading branch information...
1 parent 02d4a42 commit 222802a0ba2f6640baaae51b6b3f207b328ad8f6 @nick-jonas committed Dec 29, 2012
View
@@ -13,14 +13,12 @@ Thumbs.db
########################
app/.sass-cache
app/sass/.sass-cache
-
-# Build Directory #
-###################
-build/output
-
-
*.scssc
# Node Dependencies #
#####################
node_modules
+
+# Development #
+#####################
+examples
View
@@ -1,4 +1,8 @@
language: node_js
node_js:
- "0.8"
- - "0.6"
+ - "0.6"
+
+notifications:
+ email:
+ - njonas45@gmail.com
View
@@ -14,16 +14,21 @@ var _ = require('lodash'),
*/
var _readDir = function(dir, onCompleteFn, options){
var files = [];
- _walk(dir, function(filedir, filename, filestat){
- files.push({
- 'filedir' : filedir,
- 'filename' : filename,
- 'filestat' : filestat
- });
- }, function(err){
- if(err) console.log(err);
- onCompleteFn(files);
- }, options);
+ try{
+ _walk(dir, function(filedir, filename, filestat){
+ files.push({
+ 'filedir' : filedir,
+ 'filename' : filename,
+ 'filestat' : filestat
+ });
+ }, function(err){
+ if(err) console.log(err);
+ if(onCompleteFn) onCompleteFn(files);
+ }, options);
+ }catch(e){
+ throw e;
+ }
+
};
/**
@@ -41,13 +46,12 @@ var _walk = function(dir, action, done, options){
// will stores the number of pending async operations
var pending = 0;
// filters
- var fileFilter = _checkFilter(options.fileFilter);
- var dirFilter = _checkFilter(options.dirFilter);
+ var fileFilter = (options) ? _checkFilter(options.fileFilter) : null;
+ var dirFilter = (options) ? _checkFilter(options.dirFilter) : null;
var fail = function(err){
if(!dead){
dead = true;
- console.log(err);
done(err);
}
};
@@ -98,12 +102,22 @@ var _walk = function(dir, action, done, options){
fail(err);
}else{
if(stat && stat.isDirectory()){
- if(checkForInclude(filePath, dirFilter)){
- dive(filePath); // it's a dir, explore recursively
+ if(dirFilter){
+ // if there is a directory filter
+ if(checkForInclude(filePath, dirFilter)){
+ dive(filePath); // it's a dir, explore recursively
+ }
+ }else{
+ dive(filePath);
}
}else{
- if(checkForInclude(filePath, fileFilter)){
- performAction(path.relative(dir, thisDir) + '/', file, stat); // it's not a dir, perform the action
+ if(fileFilter){
+ // if there is a file filter
+ if(checkForInclude(filePath, fileFilter)){
+ performAction(path.relative(dir, thisDir) + '/', file, stat); // it's not a dir, perform the action
+ }
+ }else{
+ performAction(path.relative(dir, thisDir) + '/', file, stat);
}
}
pending--; checkSuccess(); // async operation complete
No changes.
No changes.
No changes.
No changes.
No changes.
View
No changes.
View
No changes.
View
No changes.
View
@@ -0,0 +1,17 @@
+var vows = require('vows'),
+ path = require('path'),
+ assert = require('assert'),
+ fs = require('fs'),
+ reader = require('../lib/commands/reader');
+
+// test walk
+vows.describe('Read Directory').addBatch({
+ 'A file bed': {
+ topic: function(){
+ reader.readDir(path.join(__dirname, 'bed'), this.callback);
+ },
+ 'should return 12 files': function(files){
+ assert.equal(files.length, 12);
+ }
+ }
+}).run();

0 comments on commit 222802a

Please sign in to comment.