|
38 | 38 | } |
39 | 39 |
|
40 | 40 | function metaFile(file) { |
41 | | - return file.path.slice(-5) === '.meta'; |
| 41 | + return !notMetaFile(file); |
42 | 42 | } |
43 | 43 |
|
44 | 44 | function handleErrorFor(file) { |
|
176 | 176 | return this.metaChildren.filter(function(t) { return !t.isDirectory; }); |
177 | 177 | }; |
178 | 178 |
|
179 | | - RamlDirectory.prototype.forEachChildDo = function forEachChildDo(action) { |
| 179 | + RamlDirectory.prototype.forEachItemDo = function forEachItemDo(action, isMetaChildren) { |
180 | 180 | // BFS |
181 | | - var queue = this.children.slice(); |
| 181 | + var queue = isMetaChildren ? this.metaChildren.slice() : this.children.slice(); |
182 | 182 | var current; |
183 | 183 |
|
184 | 184 | while (queue.length > 0) { |
185 | 185 | current = queue.shift(); |
186 | 186 |
|
187 | 187 | if (current.isDirectory) { |
188 | | - queue = queue.concat(current.children); |
| 188 | + queue = queue.concat((isMetaChildren) ? current.metaChildren : current.children); |
189 | 189 | } |
190 | 190 |
|
191 | 191 | action.call(current, current); |
192 | 192 | } |
193 | 193 | }; |
194 | 194 |
|
195 | | - RamlDirectory.prototype.forEachMetaChildDo = function forEachMetaChildDo(action) { |
196 | | - // BFS |
197 | | - var queue = this.metaChildren.slice(); |
198 | | - var current; |
199 | | - |
200 | | - while (queue.length > 0) { |
201 | | - current = queue.shift(); |
202 | | - |
203 | | - if (current.isDirectory) { |
204 | | - queue = queue.concat(current.metaChildren); |
205 | | - } |
| 195 | + RamlDirectory.prototype.forEachChildDo = function forEachChildDo(action) { |
| 196 | + this.forEachItemDo(action, false); |
| 197 | + }; |
206 | 198 |
|
207 | | - action.call(current, current); |
208 | | - } |
| 199 | + RamlDirectory.prototype.forEachMetaChildDo = function forEachChildDo(action) { |
| 200 | + this.forEachItemDo(action, true); |
209 | 201 | }; |
210 | 202 |
|
211 | 203 | RamlDirectory.prototype.sortChildren = function sortChildren() { |
|
277 | 269 | // and collect all promises into an array |
278 | 270 | var promises = []; |
279 | 271 | directory.getDirectories().forEach(function(dir) { promises.push(service.removeDirectory(dir)); }); |
280 | | - directory.getFiles().forEach(function(file) { promises.push(service.removeFile(file)); }); |
281 | | - directory.getMetaFiles().forEach(function(file) { promises.push(service.removeFile(file)); }); |
| 272 | + directory.getFiles().concat(directory.getMetaFiles()) |
| 273 | + .forEach(function(file) { promises.push(service.removeFile(file)); }); |
282 | 274 |
|
283 | 275 | // remove this directory object from parent's children list |
284 | 276 | var parent = service.getParent(directory); |
|
0 commit comments