live-server
Advanced tools
Comparing version 1.2.0 to 1.2.1
19
index.js
@@ -123,2 +123,3 @@ #!/usr/bin/env node | ||
* @param ignorePattern {regexp} Ignore files by RegExp | ||
* @param noCssInject Don't inject CSS changes, just reload as with any other file change | ||
* @param open {(string|string[])} Subpath(s) to open in browser, use false to suppress launch (default: server root) | ||
@@ -152,3 +153,17 @@ * @param mount {array} Mount directories onto a route, e.g. [['/components', './node_modules']]. | ||
var middleware = options.middleware || []; | ||
var noCssInject = options.noCssInject; | ||
var httpsModule = options.httpsModule; | ||
if (httpsModule) { | ||
try { | ||
require.resolve(httpsModule); | ||
} catch (e) { | ||
console.error(("HTTPS module \"" + httpsModule + "\" you've provided was not found.").red); | ||
console.error("Did you do", "\"npm install " + httpsModule + "\"?"); | ||
return; | ||
} | ||
} else { | ||
httpsModule = "https"; | ||
} | ||
// Setup a web server | ||
@@ -223,3 +238,3 @@ var app = connect(); | ||
} | ||
server = require("https").createServer(httpsConfig, app); | ||
server = require(httpsModule).createServer(httpsConfig, app); | ||
protocol = "https"; | ||
@@ -349,3 +364,3 @@ } else { | ||
function handleChange(changePath) { | ||
var cssChange = path.extname(changePath) === ".css"; | ||
var cssChange = path.extname(changePath) === ".css" && !noCssInject; | ||
if (LiveServer.logLevel >= 1) { | ||
@@ -352,0 +367,0 @@ if (cssChange) |
@@ -71,2 +71,6 @@ #!/usr/bin/env node | ||
} | ||
else if (arg === "--no-css-inject") { | ||
opts.noCssInject = true; | ||
process.argv.splice(i, 1); | ||
} | ||
else if (arg === "--no-browser") { | ||
@@ -132,2 +136,6 @@ opts.open = false; | ||
} | ||
else if (arg.indexOf("--https-module=") > -1) { | ||
opts.httpsModule = arg.substring(15); | ||
process.argv.splice(i, 1); | ||
} | ||
else if (arg.indexOf("--proxy=") > -1) { | ||
@@ -144,3 +152,3 @@ // split only on the first ":", as the URL will contain ":" as well | ||
else if (arg === "--help" || arg === "-h") { | ||
console.log('Usage: live-server [-v|--version] [-h|--help] [-q|--quiet] [--port=PORT] [--host=HOST] [--open=PATH] [--no-browser] [--browser=BROWSER] [--ignore=PATH] [--ignorePattern=RGXP] [--entry-file=PATH] [--spa] [--mount=ROUTE:PATH] [--wait=MILLISECONDS] [--htpasswd=PATH] [--cors] [--https=PATH] [--proxy=PATH] [PATH]'); | ||
console.log('Usage: live-server [-v|--version] [-h|--help] [-q|--quiet] [--port=PORT] [--host=HOST] [--open=PATH] [--no-browser] [--browser=BROWSER] [--ignore=PATH] [--ignorePattern=RGXP] [--no-css-inject] [--entry-file=PATH] [--spa] [--mount=ROUTE:PATH] [--wait=MILLISECONDS] [--htpasswd=PATH] [--cors] [--https=PATH] [--https-module=MODULE_NAME] [--proxy=PATH] [PATH]'); | ||
process.exit(); | ||
@@ -147,0 +155,0 @@ } |
{ | ||
"name": "live-server", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "simple development http server with live reload capability", | ||
@@ -15,10 +15,10 @@ "keywords": [ | ||
"dependencies": { | ||
"chokidar": "^1.6.0", | ||
"chokidar": "^2.0.4", | ||
"colors": "latest", | ||
"connect": "3.5.x", | ||
"connect": "^3.6.6", | ||
"cors": "latest", | ||
"event-stream": "latest", | ||
"event-stream": "3.3.4", | ||
"faye-websocket": "0.11.x", | ||
"http-auth": "3.1.x", | ||
"morgan": "^1.6.1", | ||
"morgan": "^1.9.1", | ||
"object-assign": "latest", | ||
@@ -28,9 +28,9 @@ "opn": "latest", | ||
"send": "latest", | ||
"serve-index": "^1.7.2" | ||
"serve-index": "^1.9.1" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^3.2.0", | ||
"supertest": "^2.0.1", | ||
"eslint": "^3.13.0", | ||
"jshint": "^2.9.2" | ||
"eslint": "^5.9.0", | ||
"jshint": "^2.9.6", | ||
"mocha": "^5.2.0", | ||
"supertest": "^3.3.0" | ||
}, | ||
@@ -40,3 +40,3 @@ "scripts": { | ||
"hint": "jshint live-server.js index.js", | ||
"test": "mocha test && npm run lint" | ||
"test": "mocha test --exit && npm run lint" | ||
}, | ||
@@ -43,0 +43,0 @@ "bin": { |
@@ -56,2 +56,3 @@ [![view on npm](http://img.shields.io/npm/v/live-server.svg)](https://www.npmjs.org/package/live-server) | ||
* `--ignorePattern=RGXP` - Regular expression of files to ignore (ie `.*\.jade`) (**DEPRECATED** in favor of `--ignore`) | ||
* `--no-css-inject` - reload page on CSS change, rather than injecting changed CSS | ||
* `--middleware=PATH` - path to .js file exporting a middleware function to add; can be a name without path nor extension to reference bundled middlewares in `middleware` folder | ||
@@ -65,2 +66,3 @@ * `--entry-file=PATH` - serve this file (server root relative) in place of missing files (useful for single page apps) | ||
* `--https=PATH` - PATH to a HTTPS configuration module | ||
* `--https-module=MODULE_NAME` - Custom HTTPS module (e.g. `spdy`) | ||
* `--proxy=ROUTE:URL` - proxy all requests for ROUTE to URL | ||
@@ -87,3 +89,3 @@ * `--help | -h` - display terse usage hint and exit | ||
ignore: 'scss,my/templates', // comma-separated string for paths to ignore | ||
file: "index.html", // When set, serve this file for every 404 (useful for single-page applications) | ||
file: "index.html", // When set, serve this file (server root relative) for every 404 (useful for single-page applications) | ||
wait: 1000, // Waits for all changes, before reloading. Defaults to 0 sec. | ||
@@ -117,3 +119,15 @@ mount: [['/components', './node_modules']], // Mount a directory to a route. | ||
HTTP/2 | ||
--------------- | ||
To get HTTP/2 support one can provide a custom HTTPS module via `--https-module` CLI parameter (`httpsModule` option for Node.js script). **Be sure to install the module first.** | ||
HTTP/2 unencrypted mode is not supported by browsers, thus not supported by `live-server`. See [this question](https://http2.github.io/faq/#does-http2-require-encryption) and [can I use page on HTTP/2](http://caniuse.com/#search=http2) for more details. | ||
For example from CLI(bash): | ||
live-server \ | ||
--https=path/to/https.conf.js \ | ||
--https-module=spdy \ | ||
my-app-folder/ | ||
Troubleshooting | ||
@@ -138,3 +152,3 @@ --------------- | ||
We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for details. | ||
We welcome contributions! See [CONTRIBUTING.md](.github/CONTRIBUTING.md) for details. | ||
@@ -145,2 +159,6 @@ | ||
* v1.2.1 | ||
- `--https-module=MODULE_NAME` to specify custom HTTPS module (e.g. `spdy`) (@pavel) | ||
- `--no-css-inject` to reload page on css change instead of injecting the changes (@kylecordes) | ||
- Dependencies updated to get rid of vulnerabilities in deps | ||
* v1.2.0 | ||
@@ -147,0 +165,0 @@ - Add `--middleware` parameter to use external middlewares |
@@ -20,3 +20,3 @@ var assert = require('assert'); | ||
assert(!error, error); | ||
assert(stdout.indexOf("live-server") == 0, "version not found"); | ||
assert(stdout.indexOf("live-server") === 0, "version not found"); | ||
done(); | ||
@@ -28,3 +28,3 @@ }); | ||
assert(!error, error); | ||
assert(stdout.indexOf("Usage: live-server") == 0, "usage not found"); | ||
assert(stdout.indexOf("Usage: live-server") === 0, "usage not found"); | ||
done(); | ||
@@ -43,3 +43,3 @@ }); | ||
assert(!error, error); | ||
assert(stdout.indexOf("Serving") == 0, "serving string not found"); | ||
assert(stdout.indexOf("Serving") >= 0, "serving string not found"); | ||
assert(stdout.indexOf("at http://127.0.0.1:16123") != -1, "port string not found"); | ||
@@ -52,3 +52,3 @@ done(); | ||
assert(!error, error); | ||
assert(stdout.indexOf("Serving") == 0, "serving string not found"); | ||
assert(stdout.indexOf("Serving") >= 0, "serving string not found"); | ||
assert(stdout.indexOf("at http://localhost:") != -1, "host string not found"); | ||
@@ -65,3 +65,3 @@ done(); | ||
assert(!error, error); | ||
assert(stdout.indexOf("Serving") == 0, "serving string not found"); | ||
assert(stdout.indexOf("Serving") >= 0, "serving string not found"); | ||
done(); | ||
@@ -68,0 +68,0 @@ }); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
52132
951
273
3
13
+ Addedanymatch@2.0.0(transitive)
+ Addedchokidar@2.1.8(transitive)
+ Addedconnect@3.7.0(transitive)
+ Addedevent-stream@3.3.4(transitive)
+ Addedfinalhandler@1.1.2(transitive)
+ Addedglob-parent@3.1.0(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@3.1.04.0.3(transitive)
+ Addedmap-stream@0.1.0(transitive)
+ Addednormalize-path@3.0.0(transitive)
+ Addedpath-dirname@1.0.2(transitive)
+ Addedsplit@0.3.3(transitive)
+ Addedstream-combiner@0.0.4(transitive)
+ Addedupath@1.2.0(transitive)
+ Addedutils-merge@1.0.1(transitive)
- Removedanymatch@1.3.2(transitive)
- Removedarr-diff@2.0.0(transitive)
- Removedarray-unique@0.2.1(transitive)
- Removedbraces@1.8.5(transitive)
- Removedchokidar@1.7.0(transitive)
- Removedconnect@3.5.1(transitive)
- Removeddebug@2.2.0(transitive)
- Removedevent-stream@4.0.1(transitive)
- Removedexpand-brackets@0.1.5(transitive)
- Removedexpand-range@1.8.2(transitive)
- Removedextglob@0.3.2(transitive)
- Removedfilename-regex@2.0.1(transitive)
- Removedfill-range@2.2.4(transitive)
- Removedfinalhandler@0.5.1(transitive)
- Removedfor-own@0.1.5(transitive)
- Removedglob-base@0.3.0(transitive)
- Removedglob-parent@2.0.0(transitive)
- Removedis-dotfile@1.0.3(transitive)
- Removedis-equal-shallow@0.1.3(transitive)
- Removedis-extglob@1.0.0(transitive)
- Removedis-glob@2.0.1(transitive)
- Removedis-number@2.1.04.0.0(transitive)
- Removedis-posix-bracket@0.1.1(transitive)
- Removedis-primitive@2.0.0(transitive)
- Removedmap-stream@0.0.7(transitive)
- Removedmath-random@1.0.4(transitive)
- Removedmicromatch@2.3.11(transitive)
- Removedms@0.7.1(transitive)
- Removedobject.omit@2.0.1(transitive)
- Removedparse-glob@3.0.4(transitive)
- Removedpreserve@0.2.0(transitive)
- Removedrandomatic@3.1.1(transitive)
- Removedregex-cache@0.4.4(transitive)
- Removedsplit@1.0.1(transitive)
- Removedstatuses@1.3.1(transitive)
- Removedstream-combiner@0.2.2(transitive)
- Removedutils-merge@1.0.0(transitive)
Updatedchokidar@^2.0.4
Updatedconnect@^3.6.6
Updatedevent-stream@3.3.4
Updatedmorgan@^1.9.1
Updatedserve-index@^1.9.1