| 
									
										
										
										
											2017-01-07 14:56:47 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2017-01-13 01:05:47 +08:00
										 |  |  | "use strict"; | 
					
						
							| 
									
										
										
										
											2017-01-07 14:56:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-11 12:27:09 +08:00
										 |  |  | const asyncLib = require("neo-async"); | 
					
						
							| 
									
										
										
										
											2017-01-13 01:05:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | class MultiWatching { | 
					
						
							| 
									
										
										
										
											2017-03-06 11:32:34 +08:00
										 |  |  | 	constructor(watchings, compiler) { | 
					
						
							| 
									
										
										
										
											2017-01-13 01:05:47 +08:00
										 |  |  | 		this.watchings = watchings; | 
					
						
							| 
									
										
										
										
											2017-03-06 11:32:34 +08:00
										 |  |  | 		this.compiler = compiler; | 
					
						
							| 
									
										
										
										
											2017-01-13 01:05:47 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-07 14:56:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-13 01:05:47 +08:00
										 |  |  | 	invalidate() { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const watching of this.watchings) { | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 			watching.invalidate(); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-01-13 01:05:47 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-07 14:56:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-13 01:05:47 +08:00
										 |  |  | 	close(callback) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		asyncLib.forEach( | 
					
						
							|  |  |  | 			this.watchings, | 
					
						
							|  |  |  | 			(watching, finishedCallback) => { | 
					
						
							|  |  |  | 				watching.close(finishedCallback); | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 			err => { | 
					
						
							|  |  |  | 				this.compiler.hooks.watchClose.call(); | 
					
						
							|  |  |  | 				if (typeof callback === "function") { | 
					
						
							| 
									
										
										
										
											2018-03-07 18:45:38 +08:00
										 |  |  | 					this.compiler.running = false; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					callback(err); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-01-13 01:05:47 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-07 14:56:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | module.exports = MultiWatching; |