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 -
|
$ 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/)
|
[](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"),
|
var connect = require("connect"),
|
||||||
http = require("http"),
|
http = require("http"),
|
||||||
Thing = require("nature").Thing,
|
Thing = require("nature").Thing,
|
||||||
wodge = require("wodge");
|
wodge = require("wodge");
|
||||||
|
|
||||||
|
var usage = "usage: ws [--port|-p <port>] [--log-format|-f dev|default|short|tiny]";
|
||||||
|
|
||||||
function halt(message){
|
function halt(message){
|
||||||
console.log(wodge.red("Error ") + message);
|
console.log(wodge.red("Error ") + message);
|
||||||
console.log(usage);
|
console.log(usage);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var usage = "usage: ws [--port|-p <port>] [--log-format|-f dev|default|short|tiny]";
|
|
||||||
var options = new Thing()
|
var options = new Thing()
|
||||||
.define({ name: "port", alias: "p", type: "number", defaultOption: true, value: 8000 })
|
.define({ name: "port", alias: "p", type: "number", defaultOption: true, value: 8000 })
|
||||||
.define({ name: "log-format", alias: "f", type: "string", value: "dev" })
|
.define({ name: "log-format", alias: "f", type: "string", value: "dev" })
|
||||||
@ -21,16 +22,16 @@ var options = new Thing()
|
|||||||
.set(process.argv);
|
.set(process.argv);
|
||||||
|
|
||||||
if (!options.valid){
|
if (!options.valid){
|
||||||
halt(options.validationMessages)
|
halt(options.validationMessages);
|
||||||
|
|
||||||
} else if (options.help){
|
} else if (options.help){
|
||||||
console.log(usage);
|
console.log(usage);
|
||||||
|
|
||||||
} else {
|
} 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();
|
var a = new Date();
|
||||||
return (a.getDate() + "/" + a.getUTCMonth() + "/" + a.getFullYear() + ":" + a.toTimeString())
|
return (a.getDate() + "/" + a.getUTCMonth() + "/" + a.getFullYear() + ":" + a.toTimeString())
|
||||||
.replace("GMT", "").replace(" (BST)", "");
|
.replace("GMT", "").replace(" (BST)", "");
|
||||||
@ -41,11 +42,11 @@ if (!options.valid){
|
|||||||
.use(connect.compress())
|
.use(connect.compress())
|
||||||
.use(connect.static(process.cwd()))
|
.use(connect.static(process.cwd()))
|
||||||
.use(connect.directory(process.cwd(), { icons: true }));
|
.use(connect.directory(process.cwd(), { icons: true }));
|
||||||
|
|
||||||
http.createServer(app)
|
http.createServer(app)
|
||||||
.on("error", function(err){
|
.on("error", function(err){
|
||||||
if (err.code === "EADDRINUSE"){
|
if (err.code === "EADDRINUSE"){
|
||||||
halt("port " + options.port + " is already is use")
|
halt("port " + options.port + " is already is use");
|
||||||
} else {
|
} else {
|
||||||
halt(err.message);
|
halt(err.message);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user