Skip to content

Commit

Permalink
feat: add ability to set host address
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlescure committed Dec 11, 2020
1 parent e47c917 commit a56a2c6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
7 changes: 4 additions & 3 deletions bin/fasthr
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
const [,, ...args] = process.argv;

const {options} = require('./getopts').create([
['d' , 'dir=ARG', 'root directory where to serve files from.'],
['p' , 'port=ARG', 'port to run server on.'],
['l' , 'livePort=ARG', 'port to run livereload on.'],
['d', 'dir=ARG', 'root directory where to serve files from (default: current directory).'],
['p', 'port=ARG', 'port to run server on (default: 3000).'],
['a', 'address=ARG', 'address to run server on (default: 0.0.0.0).'],
['l', 'livePort=ARG', 'port to run livereload on.'],
])
.bindHelp()
.parseSystem();
Expand Down
4 changes: 2 additions & 2 deletions bin/server.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fasthr",
"version": "1.0.2",
"version": "1.1.2",
"description": "A fast and tiny CLI tool to easily spin up a hot reload http server on the current directory",
"bin": {
"fasthr": "bin/fasthr"
Expand Down
4 changes: 3 additions & 1 deletion server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ const defaults = {
dir: process.cwd(),
port: 3000,
livePort: 35729,
address: '0.0.0.0',
};

export default async (options) => {
const {
dir,
port,
livePort,
address,
}: any = {
...defaults,
...options,
Expand Down Expand Up @@ -58,7 +60,7 @@ export default async (options) => {
});

try {
await server.listen(port);
await server.listen(port, address);
} catch (err) {
server.log.error(err);
process.exit(1);
Expand Down

0 comments on commit a56a2c6

Please sign in to comment.