readme, lint
This commit is contained in:
		
							
								
								
									
										18
									
								
								.jshintrc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								.jshintrc
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,18 @@ | ||||
| { | ||||
|     "bitwise": true, | ||||
|     "camelcase": true, | ||||
|     "eqeqeq": true, | ||||
|     "globals": { "describe" : false, "it": false, "beforeEach": false }, | ||||
|     "globalstrict": false, | ||||
|     "indent": 4, | ||||
|     "latedef": true, | ||||
|     "laxbreak": true, | ||||
|     "maxparams": 3, | ||||
|     "multistr": true, | ||||
|     "newcap": true, | ||||
|     "node": true, | ||||
|     "quotmark": "double", | ||||
|     "trailing": true, | ||||
|     "undef": true, | ||||
|     "unused": "strict" | ||||
| } | ||||
							
								
								
									
										20
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								README.md
									
									
									
									
									
								
							| @ -54,4 +54,24 @@ Alternatively, pipe directly from ws into logstalgia for real-time visualisation | ||||
| $ ws --log-format default | logstalgia - | ||||
| ``` | ||||
|  | ||||
| Use with glTail | ||||
| --------------- | ||||
| To use with [glTail](http://www.fudgie.org), write your log to disk using the "default" format:  | ||||
| ```sh | ||||
| $ ws -f default > web.log | ||||
| ``` | ||||
|  | ||||
| Then specify this file in your glTail config:  | ||||
|  | ||||
| ```yaml | ||||
| servers: | ||||
|     dev: | ||||
|         host: localhost | ||||
|         source: local | ||||
|         files: /Users/Lloyd/Documents/MySite/web.log | ||||
|         parser: apache | ||||
|         color: 0.2, 0.2, 1.0, 1.0 | ||||
| ``` | ||||
|  | ||||
|  | ||||
| [](https://nodei.co/npm/local-web-server/) | ||||
|  | ||||
							
								
								
									
										15
									
								
								ws.js
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								ws.js
									
									
									
									
									
								
							| @ -1,16 +1,17 @@ | ||||
| #!/usr/bin/env node  | ||||
| #!/usr/bin/env node | ||||
| var connect = require("connect"), | ||||
|     http = require("http"), | ||||
|     Thing = require("nature").Thing, | ||||
|     wodge = require("wodge"); | ||||
|  | ||||
| var usage = "usage: ws [--port|-p <port>] [--log-format|-f dev|default|short|tiny]"; | ||||
|  | ||||
| function halt(message){ | ||||
|     console.log(wodge.red("Error ") + message); | ||||
|     console.log(usage); | ||||
|     process.exit(1); | ||||
| } | ||||
|  | ||||
| var usage = "usage: ws [--port|-p <port>] [--log-format|-f dev|default|short|tiny]"; | ||||
| var options = new Thing() | ||||
|     .define({ name: "port", alias: "p", type: "number", defaultOption: true, value: 8000 }) | ||||
|     .define({ name: "log-format", alias: "f", type: "string", value: "dev" }) | ||||
| @ -21,16 +22,16 @@ var options = new Thing() | ||||
|     .set(process.argv); | ||||
|  | ||||
| if (!options.valid){ | ||||
|     halt(options.validationMessages) | ||||
|     halt(options.validationMessages); | ||||
|  | ||||
| } else if (options.help){ | ||||
|     console.log(usage); | ||||
|  | ||||
| } else { | ||||
|     /** | ||||
|     customised connect.logger :date token, purely to satisfy Logstalgia.  | ||||
|     customised connect.logger :date token, purely to satisfy Logstalgia. | ||||
|     */ | ||||
|     connect.logger.token('date', function(req, res){  | ||||
|     connect.logger.token("date", function(){ | ||||
|         var a = new Date(); | ||||
|         return (a.getDate() + "/" + a.getUTCMonth() + "/" + a.getFullYear() + ":" + a.toTimeString()) | ||||
|                 .replace("GMT", "").replace(" (BST)", ""); | ||||
| @ -41,11 +42,11 @@ if (!options.valid){ | ||||
|         .use(connect.compress()) | ||||
|         .use(connect.static(process.cwd())) | ||||
|         .use(connect.directory(process.cwd(), { icons: true })); | ||||
|          | ||||
|  | ||||
|     http.createServer(app) | ||||
|         .on("error", function(err){ | ||||
|             if (err.code === "EADDRINUSE"){ | ||||
|                 halt("port " + options.port + " is already is use") | ||||
|                 halt("port " + options.port + " is already is use"); | ||||
|             } else { | ||||
|                 halt(err.message); | ||||
|             } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user