Browse Source

add non-current-working-directory support

master
Andrew Sidesinger 11 years ago
parent
commit
758ba05bd1
  1. 5
      README.md
  2. 7
      ws.js

5
README.md

@ -24,6 +24,11 @@ $ ws
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`:
```sh
$ ws --port 9000

7
ws.js

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

Loading…
Cancel
Save