| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-05 21:06:23 +08:00
										 |  |  | const asyncLib = require("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() { | 
					
						
							|  |  |  | 		this.watchings.forEach((watching) => watching.invalidate()); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-07 14:56:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-13 01:05:47 +08:00
										 |  |  | 	close(callback) { | 
					
						
							| 
									
										
										
										
											2017-03-06 11:32:34 +08:00
										 |  |  | 		if(callback === undefined) callback = () => { /*do nothing*/ }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-05 21:06:23 +08:00
										 |  |  | 		asyncLib.forEach(this.watchings, (watching, finishedCallback) => { | 
					
						
							| 
									
										
										
										
											2017-01-13 01:05:47 +08:00
										 |  |  | 			watching.close(finishedCallback); | 
					
						
							| 
									
										
										
										
											2017-03-06 11:32:34 +08:00
										 |  |  | 		}, err => { | 
					
						
							| 
									
										
										
										
											2017-11-28 22:01:41 +08:00
										 |  |  | 			this.compiler.hooks.watchClose.call(); | 
					
						
							| 
									
										
										
										
											2017-03-06 11:32:34 +08:00
										 |  |  | 			callback(err); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-13 01:05:47 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-07 14:56:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | module.exports = MultiWatching; |