Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
add option to open site on server run
Browse files Browse the repository at this point in the history
  • Loading branch information
paularmstrong committed Oct 23, 2012
1 parent 48d37d2 commit 1239304
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -108,6 +108,8 @@ This means that a URL to the `contact` page should be `/about/contact/`.
* `-p`, `--port`
* Server port
* [default: 3000]
* `-o`, `--open`
* Open your site in a web browser
* `--encoding`
* File encoding (input and output)
* [default: "utf-8"]
Expand Down
8 changes: 7 additions & 1 deletion bin/server
@@ -1,18 +1,21 @@
#!/usr/bin/env node

var server = require('../').server,
optimist = require('optimist');
optimist = require('optimist'),
opener = require('opener');

var argv = optimist
.usage('Usage: still-server [path] [options]')
.describe({
e: 'Template engine',
p: 'Server port',
o: 'Open your site in a web browser',
encoding: 'File encoding (input and output)',
verbose: 'Verbosity mode: 0 = silent, 1 = default, 2 = warnings, 3 = debug'
})
.alias('e', 'engine')
.alias('p', 'port')
.alias('o', 'open')
.default('e', 'swig')
.default('p', 3000)
.default('encoding', 'utf-8')
Expand All @@ -24,3 +27,6 @@ if (!argv._.length) {
}

server.run(argv);
if (argv.o) {
opener('http://localhost:' + argv.p);
}
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -39,7 +39,8 @@
"findit": "~0.1",
"lodash": "~0.8",
"mkdirp": "~0.3",
"optimist": "~0.3"
"optimist": "~0.3",
"opener": "~1.3"
},
"devDependencies": {
"swig": "~0.13",
Expand Down

0 comments on commit 1239304

Please sign in to comment.