fix #41 by reporting nodeError if first directory fails
This commit is contained in:
parent
01a28a0d2b
commit
0d6bda5385
12
lib/walk.js
12
lib/walk.js
|
@ -159,25 +159,31 @@
|
|||
me._wfnodegroups = fnodeGroups;
|
||||
me._wcurfiles = files;
|
||||
|
||||
|
||||
// no error, great
|
||||
if (!err) {
|
||||
me._wReadFiles();
|
||||
return;
|
||||
}
|
||||
|
||||
// error? not first run? => directory error
|
||||
if (!me._wfirstrun) {
|
||||
me.emit('directoryError', me._wcurpath, { error: err }, noop);
|
||||
me._wReadFiles();
|
||||
return;
|
||||
}
|
||||
|
||||
// error? first run? => maybe a file, maybe a true error
|
||||
me._wfirstrun = false;
|
||||
// TODO how to remove this anony?
|
||||
|
||||
// readdir failed, try stat (might be a file)
|
||||
me._wcurpath = me._wcurpath.replace(/^.*\/$/, '');
|
||||
fs[me._wStat](me._wcurpath, function (e, stat) {
|
||||
|
||||
if (stat) {
|
||||
files = [me._wcurpath.replace(/.*\//, '')];
|
||||
files = [me._wcurpath];
|
||||
me._wcurpath = me._wcurpath.replace(files[0], '');
|
||||
} else {
|
||||
me.emit('nodeError', me._wcurpath, { error: err }, noop);
|
||||
}
|
||||
|
||||
me._wReadFiles();
|
||||
|
|
Loading…
Reference in New Issue