Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ npm install -g pushstate-server
```

```
usage: pushstate-server [-d directory] [-p port] [-f file]
usage: pushstate-server [-d directory] [-h host] [-p port] [-f file]
```

## API
Expand All @@ -60,6 +60,9 @@ usage: pushstate-server [-d directory] [-p port] [-f file]

##### options

* `host`
* set the host that the server should open
* uses ` process.env.HOST ` if not specified, and defaults to host ` 0.0.0.0 ` if none is available
* `port`
* set the port that the server should open
* uses ` process.env.PORT ` if not specified, and defaults to port ` 9000 ` if none is available
Expand Down
6 changes: 4 additions & 2 deletions bin/pushstate-server
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
const server = require('../index')
const argv = require('minimist')(process.argv.slice(2))

if (argv.h || argv.help) {
if (argv.help) {
console.log([
'usage: pushstate-server [options]',
'',
'options:',
' -d Directory to serve [public]',
' -h Host to use [0.0.0.0].',
' -p Port to use [9000]',
' -f Custom file to serve [index.html]',
' -h --help Print this list and exit.'
' --help Print this list and exit.'
].join('\n'));
process.exit();
}

server.start({
directory: argv.d,
host: argv.h,
port: argv.p,
file: argv.f
}, (err, address) =>
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const HOST = "0.0.0.0";
exports.start = function(options, _onStarted) {
options = options || {};

let host = options.host || process.env.HOST || HOST;
let port = options.port || process.env.PORT || PORT;
let directory = options.directory || DIRECTORY;
let directories = options.directories || [directory];
let file = options.file || FILE;
let host = options.host || HOST;
let onStarted = _onStarted || function() {};

app.use(compression());
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.