Browse Source

Merging in PR #1

master
Lloyd Brookes 11 years ago
parent
commit
62d449eb15
  1. 5
      README.md
  2. 7
      ws.js

5
README.md

@ -24,6 +24,11 @@ $ ws
serving at http://localhost:8000 serving at http://localhost:8000
``` ```
If you wish to serve a different directory, run:
```sh
$ ws -d ~/mysite/
```
If you wish to override the default port (8000), use `--port` or `-p`: If you wish to override the default port (8000), use `--port` or `-p`:
```sh ```sh
$ ws --port 9000 $ ws --port 9000

7
ws.js

@ -4,7 +4,7 @@ var connect = require("connect"),
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]";
var usage = "usage: ws [--directory|-d <directory>] [--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);
@ -16,6 +16,7 @@ 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" })
.define({ name: "help", alias: "h", type: "boolean" }) .define({ name: "help", alias: "h", type: "boolean" })
.define({ name: "directory", alias: "d", type: "string", value: process.cwd() })
.on("error", function(err){ .on("error", function(err){
halt(err.message); halt(err.message);
}) })
@ -40,8 +41,8 @@ if (!options.valid){
var app = connect() var app = connect()
.use(connect.logger(options["log-format"])) .use(connect.logger(options["log-format"]))
.use(connect.compress()) .use(connect.compress())
.use(connect.static(process.cwd()))
.use(connect.directory(process.cwd(), { icons: true }));
.use(connect.static(options.directory))
.use(connect.directory(options.directory, { icons: true }));
http.createServer(app) http.createServer(app)
.on("error", function(err){ .on("error", function(err){

Loading…
Cancel
Save