mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-17 04:26:00 +00:00
Modules
This commit is contained in:
33
node_modules/walkdir/test/async.js
generated
vendored
Normal file
33
node_modules/walkdir/test/async.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
var test = require('tape');
|
||||
var walkdir = require('../walkdir.js');
|
||||
var path = require('path');
|
||||
|
||||
var expectedPaths = {
|
||||
'dir/foo/x':'file',
|
||||
'dir/foo/a':'dir',
|
||||
'dir/foo/a/y':'file',
|
||||
'dir/foo/a/b':'dir',
|
||||
'dir/foo/a/b/z':'file',
|
||||
'dir/foo/a/b/c':'dir',
|
||||
'dir/foo/a/b/c/w':'file'
|
||||
};
|
||||
|
||||
|
||||
test("can use async method with promise",(t)=>{
|
||||
if(typeof Promise === 'undefined'){
|
||||
console.log('cannot use async promise returning methods in runtime without Promise')
|
||||
return t.end()
|
||||
}
|
||||
|
||||
var p = walkdir.async(path.join(__dirname,'dir'))
|
||||
|
||||
p.then(function(result){
|
||||
result = result.map(function(p){
|
||||
return p.replace(__dirname,'')
|
||||
})
|
||||
t.ok(result.indexOf('/dir/symlinks/dir1/dangling-symlink') > -1,'should be a list of found files and have found one in particular')
|
||||
t.end()
|
||||
}).catch(function(e){
|
||||
t.fail(e);
|
||||
})
|
||||
})
|
33
node_modules/walkdir/test/comparison/find.js
generated
vendored
Normal file
33
node_modules/walkdir/test/comparison/find.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
var spawn = require('child_process').spawn;
|
||||
|
||||
var find = spawn('find',[process.argv[2]||'./']);
|
||||
|
||||
var fs = require('fs');
|
||||
|
||||
var buf = '',count = 0;
|
||||
|
||||
handleBuf = function(data){
|
||||
|
||||
buf += data;
|
||||
|
||||
if(buf.length >= 1024) {
|
||||
var lines = buf.split("\n");
|
||||
buf = lines.pop();//last line my not be complete
|
||||
count += lines.length;
|
||||
process.stdout.write(lines.join("\n")+"\n");
|
||||
}
|
||||
};
|
||||
|
||||
find.stdout.on('data',function(data){
|
||||
//buf += data.toString();
|
||||
handleBuf(data)
|
||||
//process.stdout.write(data.toString());
|
||||
});
|
||||
|
||||
find.on('end',function(){
|
||||
handleBuf("\n");
|
||||
console.log('found '+count+' files');
|
||||
console.log('ended');
|
||||
});
|
||||
|
||||
find.stdin.end();
|
26
node_modules/walkdir/test/comparison/find.py
generated
vendored
Normal file
26
node_modules/walkdir/test/comparison/find.py
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
rootdir = sys.argv[1]
|
||||
ino = {}
|
||||
buf = []
|
||||
for root, subFolders, files in os.walk(rootdir):
|
||||
|
||||
for filename in files:
|
||||
filePath = os.path.join(root, filename)
|
||||
try:
|
||||
stat = os.lstat(filePath)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
inostr = stat.st_ino
|
||||
|
||||
if inostr not in ino:
|
||||
ino[stat.st_ino] = 1
|
||||
buf.append(filePath);
|
||||
buf.append("\n");
|
||||
if len(buf) >= 1024:
|
||||
sys.stdout.write(''.join(buf))
|
||||
buf = []
|
||||
|
||||
sys.stdout.write(''.join(buf));
|
15
node_modules/walkdir/test/comparison/finditsynctest.js
generated
vendored
Normal file
15
node_modules/walkdir/test/comparison/finditsynctest.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
var findit = require('findit');
|
||||
|
||||
var files = findit.findSync(process.argv[2]||'./');
|
||||
|
||||
var count = files.length;
|
||||
|
||||
console.log(files);
|
||||
|
||||
files = files.join("\n");
|
||||
|
||||
process.stdout.write(files+"\n");
|
||||
|
||||
console.log('found '+count+' files');
|
||||
|
||||
|
14
node_modules/walkdir/test/comparison/findittest.js
generated
vendored
Normal file
14
node_modules/walkdir/test/comparison/findittest.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
var findit = require('findit');
|
||||
|
||||
var find = findit.find(process.argv[2]||'./');
|
||||
|
||||
var count = 0;
|
||||
|
||||
find.on('file',function(path,stat){
|
||||
count++;
|
||||
process.stdout.write(path+"\n");
|
||||
});
|
||||
|
||||
find.on('end',function(){
|
||||
console.log('found '+count+' regular files');
|
||||
});
|
24
node_modules/walkdir/test/comparison/fstream.js
generated
vendored
Normal file
24
node_modules/walkdir/test/comparison/fstream.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
var fstream = require('fstream');
|
||||
|
||||
var pipe = fstream.Reader(process.argv[2]||"../");
|
||||
|
||||
var count = 0,errorHandler;
|
||||
|
||||
pipe.on('entry',function fn(entry){
|
||||
if(entry.type == "Directory"){
|
||||
entry.on('entry',fn);
|
||||
} else if(entry.type == "File") {
|
||||
count++;
|
||||
}
|
||||
entry.on('error',errorHandler);
|
||||
});
|
||||
|
||||
pipe.on('error',(errorHandler = function(error){
|
||||
console.log('error event ',error);
|
||||
}));
|
||||
|
||||
pipe.on('end',function(){
|
||||
console.log('end! '+count);
|
||||
});
|
||||
|
||||
//this is pretty slow
|
1
node_modules/walkdir/test/comparison/install_test_deps.sh
generated
vendored
Normal file
1
node_modules/walkdir/test/comparison/install_test_deps.sh
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
npm install
|
18
node_modules/walkdir/test/comparison/lsr.js
generated
vendored
Normal file
18
node_modules/walkdir/test/comparison/lsr.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
var lsr = require('ls-r');
|
||||
|
||||
lsr(process.argv[2]||'./',{maxDepth:500000,recursive:true},function(err,origPath,args){
|
||||
if(err) {
|
||||
console.log('eww an error! ',err);
|
||||
return;
|
||||
}
|
||||
//console.log('hit');
|
||||
var c = 0;
|
||||
args.forEach(function(stat){
|
||||
if(stat.isFile()){
|
||||
console.log(stat.path);
|
||||
c++;
|
||||
}
|
||||
});
|
||||
|
||||
console.log('found '+args.length+" regular files");
|
||||
});
|
10
node_modules/walkdir/test/comparison/package.json
generated
vendored
Normal file
10
node_modules/walkdir/test/comparison/package.json
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"name":"recursedir-comparisons",
|
||||
"version": "0.0.0",
|
||||
"author": "Ryan Day <soldair@gmail.com>",
|
||||
"devDependencies": {
|
||||
"findit": "*",
|
||||
"ls-r":"*",
|
||||
"fstream":"*"
|
||||
}
|
||||
}
|
34
node_modules/walkdir/test/custom_fs.js
generated
vendored
Normal file
34
node_modules/walkdir/test/custom_fs.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
var test = require('tape'),
|
||||
_fs = require('fs'),
|
||||
walkdir = require('../walkdir.js');
|
||||
|
||||
var expectedPaths = {};
|
||||
|
||||
test('fs option',function(t){
|
||||
var paths = [];
|
||||
|
||||
var emitter = walkdir(__dirname+'/dir/foo',{fs:
|
||||
{
|
||||
readdir: function () {
|
||||
var cb = arguments[arguments.length - 1];
|
||||
cb(null, []);
|
||||
},
|
||||
lstat: function (file) {
|
||||
var cb = arguments[arguments.length - 1];
|
||||
return _fs.lstat(__dirname, cb);
|
||||
}
|
||||
}
|
||||
},function(path,stat,depth){
|
||||
t.fail('there should be no files emitted');
|
||||
});
|
||||
|
||||
emitter.on('end',function(){
|
||||
var expected = Object.keys(expectedPaths);
|
||||
t.ok(expected.length == paths.length, 'expected and emitted paths should have the same length');
|
||||
paths.forEach(function(v){
|
||||
t.ok(expected.indexOf(v) > -1,'all expected files should be in paths');
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
});
|
0
node_modules/walkdir/test/dir/foo/a/b/c/w
generated
vendored
Normal file
0
node_modules/walkdir/test/dir/foo/a/b/c/w
generated
vendored
Normal file
0
node_modules/walkdir/test/dir/foo/a/b/z
generated
vendored
Normal file
0
node_modules/walkdir/test/dir/foo/a/b/z
generated
vendored
Normal file
0
node_modules/walkdir/test/dir/foo/a/y
generated
vendored
Normal file
0
node_modules/walkdir/test/dir/foo/a/y
generated
vendored
Normal file
0
node_modules/walkdir/test/dir/foo/x
generated
vendored
Normal file
0
node_modules/walkdir/test/dir/foo/x
generated
vendored
Normal file
1
node_modules/walkdir/test/dir/nested-symlink/found-me
generated
vendored
Normal file
1
node_modules/walkdir/test/dir/nested-symlink/found-me
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
found me!
|
0
node_modules/walkdir/test/dir/symlinks/dir1/file1
generated
vendored
Normal file
0
node_modules/walkdir/test/dir/symlinks/dir1/file1
generated
vendored
Normal file
0
node_modules/walkdir/test/dir/symlinks/dir2/file2
generated
vendored
Normal file
0
node_modules/walkdir/test/dir/symlinks/dir2/file2
generated
vendored
Normal file
0
node_modules/walkdir/test/dir/symlinks/file
generated
vendored
Normal file
0
node_modules/walkdir/test/dir/symlinks/file
generated
vendored
Normal file
66
node_modules/walkdir/test/emitter.js
generated
vendored
Normal file
66
node_modules/walkdir/test/emitter.js
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
var test = require('tape'),
|
||||
walkdir = require('../walkdir.js');
|
||||
|
||||
var expectedPaths = {
|
||||
'dir/foo/x':'file',
|
||||
'dir/foo/a':'dir',
|
||||
'dir/foo/a/y':'file',
|
||||
'dir/foo/a/b':'dir',
|
||||
'dir/foo/a/b/z':'file',
|
||||
'dir/foo/a/b/c':'dir',
|
||||
'dir/foo/a/b/c/w':'file'
|
||||
};
|
||||
|
||||
test('async events',function(t){
|
||||
var paths = [],
|
||||
files = [],
|
||||
dirs = [];
|
||||
|
||||
|
||||
var emitter = walkdir(__dirname+'/dir/foo',function(path){
|
||||
//console.log('path: ',path);
|
||||
paths.push(path.replace(__dirname+'/',''));
|
||||
});
|
||||
|
||||
emitter.on('directory',function(path,stat){
|
||||
dirs.push(path.replace(__dirname+'/',''));
|
||||
});
|
||||
|
||||
emitter.on('file',function(path,stat){
|
||||
//console.log('file: ',path);
|
||||
files.push(path.replace(__dirname+'/',''));
|
||||
});
|
||||
|
||||
emitter.on('end',function(){
|
||||
|
||||
files.forEach(function(v,k){
|
||||
t.equals(expectedPaths[v],'file','path from file event should be file');
|
||||
});
|
||||
|
||||
var expected = Object.keys(expectedPaths);
|
||||
|
||||
t.ok(expected.length == paths.length, 'expected and emitted paths should have the same length');
|
||||
|
||||
expected.forEach(function(v,k){
|
||||
if(expectedPaths[v] == 'file') {
|
||||
t.ok(files.indexOf(v) > -1,'should have file in files array');
|
||||
}
|
||||
});
|
||||
|
||||
dirs.forEach(function(v,k){
|
||||
t.equals(expectedPaths[v],'dir','path from dir event should be dir '+v);
|
||||
});
|
||||
|
||||
expected.forEach(function(v,k){
|
||||
if(expectedPaths[v] == 'dir') {
|
||||
t.ok(dirs.indexOf(v) > -1,'should have dir in dirs array');
|
||||
}
|
||||
});
|
||||
|
||||
expected.forEach(function(v,k){
|
||||
t.ok(paths.indexOf(v) !== -1,'should have found all expected paths '+v);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
});
|
19
node_modules/walkdir/test/endearly.js
generated
vendored
Normal file
19
node_modules/walkdir/test/endearly.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
var test = require('tape'),
|
||||
walk = require('../walkdir.js');
|
||||
|
||||
test('should be able to end walk after first path',function(t){
|
||||
|
||||
var paths = [];
|
||||
|
||||
var em = walk('../',function(path){
|
||||
paths.push(path);
|
||||
this.end();
|
||||
});
|
||||
|
||||
em.on('end',function(){
|
||||
t.equals(paths.length,1,'should have only found one path');
|
||||
t.end();
|
||||
});
|
||||
|
||||
});
|
||||
|
51
node_modules/walkdir/test/filter.js
generated
vendored
Normal file
51
node_modules/walkdir/test/filter.js
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
var test = require('tape');
|
||||
var walkdir = require('../walkdir.js');
|
||||
var path = require('path');
|
||||
|
||||
test("can use filter option returning array",(t)=>{
|
||||
|
||||
var filterFn = function(dirPath,files){
|
||||
return files.filter((name)=>name != 'nested-symlink')
|
||||
}
|
||||
|
||||
var p = walkdir.async(path.join(__dirname,'dir'),{filter:filterFn})
|
||||
|
||||
p.then(function(result){
|
||||
result = result.map(function(p){
|
||||
return p.replace(__dirname,'')
|
||||
})
|
||||
|
||||
t.ok(result.join(',').indexOf('nested-symlink') === -1,'should have no mention of nested-symlink if filtered')
|
||||
t.end()
|
||||
}).catch(function(e){
|
||||
t.fail(e);
|
||||
})
|
||||
})
|
||||
|
||||
test("can use filter option returning promise",(t)=>{
|
||||
if(typeof Promise === 'undefined'){
|
||||
console.log('cannot use async promise returning methods in runtime without Promise')
|
||||
return t.end()
|
||||
}
|
||||
|
||||
var filterFn = function(dirPath,files){
|
||||
return new Promise(function (resolve,reject){
|
||||
files = files.filter((name)=>name != 'nested-symlink')
|
||||
resolve(files);
|
||||
})
|
||||
}
|
||||
|
||||
var p = walkdir.async(path.join(__dirname,'dir'),{filter:filterFn})
|
||||
|
||||
p.then(function(result){
|
||||
result = result.map(function(p){
|
||||
return p.replace(__dirname,'')
|
||||
})
|
||||
|
||||
t.ok(result.join(',').indexOf('nested-symlink') === -1,'should have no mention of nested-symlink if filtered')
|
||||
t.end()
|
||||
}).catch(function(e){
|
||||
t.fail(e);
|
||||
})
|
||||
})
|
||||
|
19
node_modules/walkdir/test/ignore-during.js
generated
vendored
Normal file
19
node_modules/walkdir/test/ignore-during.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
var test = require('tape')
|
||||
var walkdir = require('../')
|
||||
|
||||
test('async events',function(t){
|
||||
var paths = [],
|
||||
files = [],
|
||||
dirs = [];
|
||||
|
||||
var emitter = walkdir(__dirname+'/dir/foo',function(path){
|
||||
paths.push(path.replace(__dirname+'/',''));
|
||||
if(path === __dirname+'/dir/foo/a') this.ignore(__dirname+'/dir/foo/a');
|
||||
})
|
||||
|
||||
emitter.on('end',function(){
|
||||
t.equals(paths.sort().join('|'),'dir/foo/a|dir/foo/x','should have ignored under a');
|
||||
t.end();
|
||||
})
|
||||
|
||||
})
|
18
node_modules/walkdir/test/ignore-first.js
generated
vendored
Normal file
18
node_modules/walkdir/test/ignore-first.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
var test = require('tape')
|
||||
var walkdir = require('../')
|
||||
|
||||
test('async events',function(t){
|
||||
var paths = [],
|
||||
files = [],
|
||||
dirs = [];
|
||||
|
||||
var emitter = walkdir(__dirname+'/dir/foo',function(path){
|
||||
paths.push(path.replace(__dirname+'/',''));
|
||||
}).ignore(__dirname+'/dir/foo');
|
||||
|
||||
emitter.on('end',function(){
|
||||
t.equals(paths.length,0,'should have no paths')
|
||||
t.end();
|
||||
})
|
||||
|
||||
})
|
18
node_modules/walkdir/test/ignore.js
generated
vendored
Normal file
18
node_modules/walkdir/test/ignore.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
var test = require('tape')
|
||||
var walkdir = require('../')
|
||||
|
||||
test('async events',function(t){
|
||||
var paths = [],
|
||||
files = [],
|
||||
dirs = [];
|
||||
|
||||
var emitter = walkdir(__dirname+'/dir/foo',function(path){
|
||||
paths.push(path.replace(__dirname+'/',''));
|
||||
}).ignore(__dirname+'/dir/foo/a');
|
||||
|
||||
emitter.on('end',function(){
|
||||
t.equals(paths.sort().join('|'),'dir/foo/a|dir/foo/x','should have ignored under a');
|
||||
t.end();
|
||||
})
|
||||
|
||||
})
|
30
node_modules/walkdir/test/max_depth.js
generated
vendored
Normal file
30
node_modules/walkdir/test/max_depth.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
var test = require('tape'),
|
||||
walkdir = require('../walkdir.js');
|
||||
|
||||
var expectedPaths = {
|
||||
'dir/foo/x':'file',
|
||||
'dir/foo/a':'dir',
|
||||
'dir/foo/a/y':'file',
|
||||
'dir/foo/a/b':'dir'
|
||||
};
|
||||
|
||||
test('no_recurse option',function(t){
|
||||
var paths = [];
|
||||
|
||||
var emitter = walkdir(__dirname+'/dir/foo',{max_depth:2},function(path,stat,depth){
|
||||
paths.push(path.replace(__dirname+'/',''));
|
||||
t.ok(depth < 3,' all paths emitted should have a depth less than 3');
|
||||
});
|
||||
|
||||
emitter.on('end',function(){
|
||||
var expected = Object.keys(expectedPaths);
|
||||
|
||||
t.ok(expected.length == paths.length, 'expected and emitted paths should have the same length');
|
||||
|
||||
paths.forEach(function(v){
|
||||
t.ok(expected.indexOf(v) > -1,'paths should not have any unexpected files');
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
});
|
43
node_modules/walkdir/test/nested-symlink.js
generated
vendored
Normal file
43
node_modules/walkdir/test/nested-symlink.js
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
var test = require('tape')
|
||||
var walkdir = require('../walkdir.js')
|
||||
var basename = require('path').basename
|
||||
|
||||
test('follow symlinks',function(t){
|
||||
|
||||
var links = [],paths = [],failures = [],errors = [], files = [];
|
||||
|
||||
var emitter = walkdir(__dirname+'/dir/nested-symlink',{follow_symlinks:true});
|
||||
|
||||
emitter.on('path',function(path,stat){
|
||||
paths.push(path);
|
||||
});
|
||||
|
||||
emitter.on('file',function(path,stat){
|
||||
files.push(path);
|
||||
});
|
||||
|
||||
emitter.on('link',function(path,stat){
|
||||
links.push(path);
|
||||
});
|
||||
|
||||
emitter.on('error',function(path,err){
|
||||
console.log('error!!', arguments);
|
||||
errors.push(arguments);
|
||||
});
|
||||
|
||||
emitter.on('fail',function(path,err){
|
||||
failures.push(path);
|
||||
});
|
||||
|
||||
emitter.on('end',function(){
|
||||
|
||||
t.equal(files.length,1)
|
||||
t.equal(basename(files[0]),'found-me','found the nested symlink')
|
||||
t.equal(paths.length,3,'should find 3 things')
|
||||
|
||||
t.ok(!failures.length,'no failures')
|
||||
|
||||
t.end();
|
||||
|
||||
});
|
||||
})
|
28
node_modules/walkdir/test/no_recurse.js
generated
vendored
Normal file
28
node_modules/walkdir/test/no_recurse.js
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
var test = require('tape'),
|
||||
walkdir = require('../walkdir.js');
|
||||
|
||||
var expectedPaths = {
|
||||
'dir/foo/x':'file',
|
||||
'dir/foo/a':'dir'
|
||||
};
|
||||
|
||||
test('no_recurse option',function(t){
|
||||
var paths = [];
|
||||
|
||||
var emitter = walkdir(__dirname+'/dir/foo',{no_recurse:true},function(path,stat,depth){
|
||||
paths.push(path.replace(__dirname+'/',''));
|
||||
t.ok(depth === 1,' all paths emitted should have a depth of 1');
|
||||
});
|
||||
|
||||
emitter.on('end',function(){
|
||||
var expected = Object.keys(expectedPaths);
|
||||
|
||||
t.ok(expected.length == paths.length, 'expected and emitted paths should have the same length');
|
||||
|
||||
paths.forEach(function(v){
|
||||
t.ok(expected.indexOf(v) > -1,'all expected files should be in paths');
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
});
|
34
node_modules/walkdir/test/nofailemptydir.js
generated
vendored
Normal file
34
node_modules/walkdir/test/nofailemptydir.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
var test = require('tape'),
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
walk = require('../walkdir.js');
|
||||
|
||||
test('should not emit fail events for empty dirs',function(t){
|
||||
fs.mkdir('./empty',function(err,data){
|
||||
if(err) {
|
||||
t.equals(err.code,'EEXIST','if error code on mkdir for fixture it should only be because it exists already');
|
||||
}
|
||||
|
||||
var paths = [];
|
||||
var dirs = [];
|
||||
var emptys = [];
|
||||
var fails = [];
|
||||
|
||||
var em = walk('./');
|
||||
|
||||
em.on('fail',function(path,err){
|
||||
fails.push(path);
|
||||
});
|
||||
|
||||
em.on('empty',function(path,err){
|
||||
emptys.push(path);
|
||||
});
|
||||
|
||||
em.on('end',function(){
|
||||
t.equals(fails.length,0,'should not have any fails');
|
||||
t.equals(path.basename(emptys[0]),'empty','should find empty dir');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
36
node_modules/walkdir/test/pauseresume.js
generated
vendored
Normal file
36
node_modules/walkdir/test/pauseresume.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
var test = require('tape'),
|
||||
walk = require('../walkdir.js');
|
||||
|
||||
test('should be able to pause walk',function(t){
|
||||
|
||||
var paths = [];
|
||||
var paused = false;
|
||||
var em = walk('./',function(path){
|
||||
if(!paused){
|
||||
em.pause();
|
||||
paused = 1;
|
||||
setTimeout(function(){
|
||||
t.equals(paths.length,1,'while paused should not emit any more paths');
|
||||
em.resume();
|
||||
},300);
|
||||
} else if(paused == 1){
|
||||
em.pause();
|
||||
paused = 2;
|
||||
setTimeout(function(){
|
||||
t.equals(paths.length,2,'while paused should not emit any more paths');
|
||||
em.resume();
|
||||
},300);
|
||||
}
|
||||
|
||||
paths.push(path);
|
||||
|
||||
});
|
||||
|
||||
em.on('end',function(){
|
||||
console.log('end, and i found ',paths.length,'paths');
|
||||
t.ok(paths.length > 1,'should have more paths before end');
|
||||
t.end();
|
||||
});
|
||||
|
||||
});
|
||||
|
37
node_modules/walkdir/test/symlink.js
generated
vendored
Normal file
37
node_modules/walkdir/test/symlink.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
var test = require('tape'),
|
||||
walkdir = require('../walkdir.js');
|
||||
|
||||
|
||||
test('follow symlinks',function(t){
|
||||
|
||||
var links = [],paths = [],failures = [],errors = [];
|
||||
|
||||
var emitter = walkdir(__dirname+'/dir/symlinks/dir2',{follow_symlinks:true});
|
||||
|
||||
emitter.on('path',function(path,stat){
|
||||
paths.push(path);
|
||||
});
|
||||
|
||||
emitter.on('link',function(path,stat){
|
||||
links.push(path);
|
||||
});
|
||||
|
||||
emitter.on('error',function(path,err){
|
||||
console.log('error!!', arguments);
|
||||
errors.push(arguments);
|
||||
});
|
||||
|
||||
emitter.on('fail',function(path,err){
|
||||
failures.push(path);
|
||||
});
|
||||
|
||||
emitter.on('end',function(){
|
||||
|
||||
t.equal(errors.length,0,'should have no errors');
|
||||
t.equal(failures.length,1,'should have a failure');
|
||||
t.ok(paths.indexOf(__dirname+'/dir/symlinks/dir1/file1') !== -1,'if follow symlinks works i would have found dir1 file1');
|
||||
t.equal(require('path').basename(failures[0]),'does-not-exist','should have fail resolviong does-not-exist which dangling-symlink points to');
|
||||
t.end();
|
||||
|
||||
});
|
||||
});
|
52
node_modules/walkdir/test/sync.js
generated
vendored
Normal file
52
node_modules/walkdir/test/sync.js
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
var test = require('tape'),
|
||||
walkdir = require('../walkdir.js');
|
||||
|
||||
var expectedPaths = {
|
||||
'dir/foo/x':'file',
|
||||
'dir/foo/a':'dir',
|
||||
'dir/foo/a/y':'file',
|
||||
'dir/foo/a/b':'dir',
|
||||
'dir/foo/a/b/z':'file',
|
||||
'dir/foo/a/b/c':'dir',
|
||||
'dir/foo/a/b/c/w':'file'
|
||||
};
|
||||
|
||||
test('sync',function(t){
|
||||
var paths = [],
|
||||
files = [],
|
||||
dirs = [];
|
||||
|
||||
var pathResult = walkdir.sync(__dirname+'/dir/foo',function(path){
|
||||
console.log('path: ',path);
|
||||
paths.push(path);
|
||||
});
|
||||
|
||||
t.ok(pathResult instanceof Array,'if return object is not specified should be an array');
|
||||
|
||||
t.equals(Object.keys(expectedPaths).length,paths.length,'should have found the same number of paths as expected');
|
||||
|
||||
|
||||
Object.keys(expectedPaths).forEach(function(v,k){
|
||||
|
||||
t.ok(paths.indexOf(__dirname+'/'+v) > -1,v+' should be found');
|
||||
});
|
||||
|
||||
t.deepEquals(paths,pathResult,'paths should be equal to pathResult');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('sync return object',function(t){
|
||||
|
||||
var pathResult = walkdir.sync(__dirname+'/dir/foo',{return_object:true});
|
||||
|
||||
t.ok(!(pathResult instanceof Array),'if return object is not specified should be an array');
|
||||
|
||||
t.equals(Object.keys(expectedPaths).length,Object.keys(pathResult).length,'should find the same number of paths as expected');
|
||||
|
||||
Object.keys(expectedPaths).forEach(function(v,k){
|
||||
t.ok(pathResult[__dirname+'/'+v],'should find path in result object');
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
Reference in New Issue
Block a user