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
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

An HTTP server with livereload included. If a file inside the folder being served is changed, added or deleted, the browser will automatically reload.


## Installing

npm install -g lr-http-server
Expand All @@ -11,15 +10,15 @@ An HTTP server with livereload included. If a file inside the folder being serve

lr-http-server [-p <port>] [-d <dir>] [-l livereloadport] [-w < watchPaths || false >] [-b]

**port** (default *8080*): Port to listen on
**port** (default _8080_): Port to listen on

**dir** (default *.*): Folder to serve
**dir** (default _._): Folder to serve

**url** (default *empty*): Path to open the specific page. *e.g.* `/#/main`
**url** (default _empty_): Path to open the specific page. _e.g._ `/#/main`

**livereloadport** (default *35729*): Port for the livereload server. If `false` the livereload is disabled.
**livereloadport** (default _35729_): Port for the livereload server. If `false` the livereload is disabled.

**watchPaths**: Comma-separated list of glob patterns for the files to watch. *e.g.* `**/*.js,**/*.css,**/*.html,**/*.xml`
**watchPaths**: Comma-separated list of glob patterns for the files to watch. _e.g._ `**/*.js,**/*.css,**/*.html,**/*.xml`

**b**: disable browser open

Expand All @@ -40,7 +39,7 @@ Default usage

All options

> lr-http-server -p 80 -d src/ -u /#/main -l 30000 -w **/*.css,*.html
> lr-http-server -p 80 -d src/ -u /#/main -l 30000 -w **/*.css,*.html

HTTP server listening on port 80
Serving <path>/src
Expand All @@ -49,4 +48,3 @@ All options
Watching files:
<path>/src/**/*.css
<path>/src/*.html

53 changes: 41 additions & 12 deletions bin/lr-http-server
Original file line number Diff line number Diff line change
@@ -1,21 +1,50 @@
#!/usr/bin/env node

var simpleHttpMime = require('../src/index.js');
var program = require('commander');
const simpleHttpMime = require("../src/index.js");
const program = require("commander");

function list(val) {
return val.split(',');
return val.split(",");
}

program
.option('-p, --port <portNumber>', 'Port number', parseInt)
.option('-d, --dir <path>', 'Directory to serve')
.option('-u, --url <path>', 'Url to opening file')
.option('-l, --livereload <portNumber>', 'Port for the livereload server. Disabled if `false`')
.option('-w, --watchFiles <paths>', 'Comma-separated list of glob patterns of files to watch', list)
.option('-b, --disableBrowserOpen', 'Disable opening a browser window on the server root')
.option('-e, --extensions <exts>', 'Comma-separated list of extensions which will be added to file name if the file not found (think like /foo -> /foo.html)', list)
.option('-D, --debounce-delay <n>', 'The applied delay for file watching in milliseconds, it can be used for grouping changes', parseFloat)
.option("-p, --port <portNumber>", "Port number", parseInt)
.option("-d, --dir <path>", "Directory to serve")
.option("-u, --url <path>", "Url to opening file")
.option(
"-l, --livereload <portNumber>",
"Port for the livereload server. Disabled if `false`"
)
.option(
"-w, --watchFiles <paths>",
"Comma-separated list of glob patterns of files to watch",
list
)
.option(
"-b, --disableBrowserOpen",
"Disable opening a browser window on the server root"
)
.option(
"-e, --extensions <exts>",
"Comma-separated list of extensions which will be added to file name if the file not found (think like /foo -> /foo.html)",
list
)
.option(
"-D, --debounce-delay <n>",
"The applied delay for file watching in milliseconds, it can be used for grouping changes",
parseFloat
)
.parse(process.argv);

simpleHttpMime(program.port, program.dir, program.url, program.livereload, program.watchFiles, !program.disableBrowserOpen, program.extensions, program.debounceDelay);
const options = program.opts();

simpleHttpMime(
options.port,
options.dir,
options.url,
options.livereload,
options.watchFiles,
!options.disableBrowserOpen,
options.extensions,
options.debounceDelay
);
Loading