| 
									
										
										
										
											2018-04-16 14:55:47 -07:00
										 |  |  | """Simple Bazel wrapper around npm http-server package.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | See https://www.npmjs.com/package/http-server | 
					
						
							|  |  |  | """
 | 
					
						
							| 
									
										
										
										
											2018-08-07 16:15:45 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-16 14:55:47 -07:00
										 |  |  | load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-06 14:51:37 -07:00
										 |  |  | def http_server(templated_args = [], **kwargs): | 
					
						
							| 
									
										
										
										
											2018-08-07 16:15:45 -07:00
										 |  |  |     # By default, we pass an argument pointing the http server to the | 
					
						
							|  |  |  |     # package of the caller. | 
					
						
							|  |  |  |     # This assumes there is an index.html in the package directory. | 
					
						
							|  |  |  |     if not templated_args: | 
					
						
							|  |  |  |         templated_args = [native.package_name()] | 
					
						
							| 
									
										
										
										
											2018-04-16 14:55:47 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-07 16:15:45 -07:00
										 |  |  |     nodejs_binary( | 
					
						
							|  |  |  |         node_modules = "@http-server_runtime_deps//:node_modules", | 
					
						
							|  |  |  |         entry_point = "http-server/bin/http-server", | 
					
						
							|  |  |  |         templated_args = templated_args, | 
					
						
							|  |  |  |         **kwargs | 
					
						
							|  |  |  |     ) |