File tree Expand file tree Collapse file tree 2 files changed +27
-16
lines changed Expand file tree Collapse file tree 2 files changed +27
-16
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,10 @@ class AsyncTree {
129
129
if ( ! node . childNodes [ i ] . started ) {
130
130
return node . childNodes [ i ] ;
131
131
}
132
+
133
+ if ( node . childNodes [ i ] . childNodes . length > 0 ) {
134
+ return AsyncTree . getNextChild ( node . childNodes [ i ] ) ;
135
+ }
132
136
}
133
137
134
138
return false ;
Original file line number Diff line number Diff line change 1
1
const EventEmitter = require ( 'events' ) ;
2
2
const AsyncTree = require ( './asynctree.js' ) ;
3
+ const Utils = require ( '../util/utils.js' ) ;
3
4
const Node = require ( './treenode.js' ) ;
4
5
5
6
class CommandQueue extends EventEmitter {
@@ -39,13 +40,7 @@ class CommandQueue extends EventEmitter {
39
40
clearTimeout ( this . scheduleTimeoutId ) ;
40
41
}
41
42
42
- this . scheduleTimeoutId = setTimeout ( ( ) => {
43
- this . tree
44
- . traverse ( )
45
- . catch ( err => {
46
- return err ;
47
- } ) ;
48
- } , 0 ) ;
43
+ this . scheduleTimeoutId = setTimeout ( ( ) => this . traverse ( ) , 0 ) ;
49
44
}
50
45
51
46
clearScheduled ( ) {
@@ -66,21 +61,33 @@ class CommandQueue extends EventEmitter {
66
61
return this ;
67
62
}
68
63
69
- run ( ) {
70
- if ( this . tree . started ) {
71
- return this ;
72
- }
73
-
74
- return this . tree
64
+ traverse ( ) {
65
+ this . tree
75
66
. traverse ( )
76
67
. catch ( err => {
77
68
return err ;
78
69
} )
79
70
. then ( err => {
80
- this . emit ( 'queue:finished' , err ) ;
81
-
82
- return err ;
71
+ this . done ( err ) ;
83
72
} ) ;
73
+
74
+ return this ;
75
+ }
76
+
77
+ done ( err ) {
78
+ this . emit ( 'queue:finished' , err ) ;
79
+ this . deferred . resolve ( err ) ;
80
+ }
81
+
82
+ run ( ) {
83
+ if ( this . tree . started ) {
84
+ return this ;
85
+ }
86
+
87
+ this . deferred = Utils . createPromise ( ) ;
88
+ this . traverse ( ) ;
89
+
90
+ return this . deferred . promise ;
84
91
}
85
92
}
86
93
You can’t perform that action at this time.
0 commit comments