allow without callbacks, issue #9
This commit is contained in:
		
							parent
							
								
									4e9a6c0719
								
							
						
					
					
						commit
						bd5ee84e25
					
				| @ -22,9 +22,14 @@ GLE.init = function(fn) { | ||||
|         return require("./worker.js").create(); | ||||
|     } | ||||
| 
 | ||||
|     var opts = fn(); | ||||
|     var opts; | ||||
|     if ("function" === typeof fn) { | ||||
|         opts = fn(); | ||||
|     } else if ("object" === typeof fn) { | ||||
|         opts = fn; | ||||
|     } | ||||
|     if (!opts || "object" !== typeof opts) { | ||||
|         throw new Error("the `Greenlock.init(fn)` function should return an object `{ greenlock, cluster }`"); | ||||
|         throw new Error("the `Greenlock.init(fn)` function should return an object `{ packageRoot, cluster }`"); | ||||
|     } | ||||
| 
 | ||||
|     // just for ironic humor
 | ||||
|  | ||||
| @ -48,10 +48,12 @@ Master.create = function(opts) { | ||||
|             kickoff(); | ||||
|             resolveCb(fn); | ||||
|             return master; | ||||
|         }, | ||||
|         serve: function(fn) { | ||||
|             // ignore
 | ||||
|             master.ready(fn); | ||||
|         } | ||||
|     }; | ||||
|     // backwards compat starts early...
 | ||||
|     master.serve = master.ready; | ||||
|     return master; | ||||
| }; | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										11
									
								
								single.js
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								single.js
									
									
									
									
									
								
							| @ -19,6 +19,17 @@ Single.create = function(opts) { | ||||
|             // ignore
 | ||||
|             //fn(master);
 | ||||
|             return single; | ||||
|         }, | ||||
|         serve: function(fn) { | ||||
|             // keeping backwards compat
 | ||||
|             if (1 === fn.length) { | ||||
|                 single.ready(fn); | ||||
|                 return; | ||||
|             } | ||||
|             // serving the app, right away
 | ||||
|             single.ready(function(glx) { | ||||
|                 glx.serveApp(fn); | ||||
|             }); | ||||
|         } | ||||
|     }; | ||||
|     // backwards compat starts now
 | ||||
|  | ||||
							
								
								
									
										11
									
								
								worker.js
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								worker.js
									
									
									
									
									
								
							| @ -22,6 +22,17 @@ Worker.create = function() { | ||||
|         master: function() { | ||||
|             // ignore
 | ||||
|             return worker; | ||||
|         }, | ||||
|         serve: function(fn) { | ||||
|             // keeping backwards compat
 | ||||
|             if (1 === fn.length) { | ||||
|                 worker.ready(fn); | ||||
|                 return; | ||||
|             } | ||||
|             // serving the express app, right away
 | ||||
|             worker.ready(function(glx) { | ||||
|                 glx.serveApp(fn); | ||||
|             }); | ||||
|         } | ||||
|     }; | ||||
|     // backwards compat starts early...
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user