live-server
Advanced tools
Comparing version 0.9.0 to 0.9.1
14
index.js
@@ -57,2 +57,6 @@ #!/usr/bin/env node | ||
} | ||
if (injectTag === null) { | ||
console.warn("Failed to inject refresh script!".yellow, | ||
"Couldn't find any of the tags ", injectCandidates, "from", filepath); | ||
} | ||
} | ||
@@ -106,2 +110,5 @@ } | ||
* @param root {string} Path to root directory (default: cwd) | ||
* @param watch {array} Paths to exclusively watch for changes | ||
* @param ignore {array} Paths to ignore when watching files for changes | ||
* @param ignorePattern {regexp} Ignore files by RegExp | ||
* @param open {string} Subpath to open in browser, use false to suppress launch (default: server root) | ||
@@ -119,3 +126,3 @@ * @param mount {array} Mount directories onto a route, e.g. [['/components', './node_modules']]. | ||
var mount = options.mount || []; | ||
var watchPaths = [root]; | ||
var watchPaths = options.watch || [root]; | ||
var logLevel = options.logLevel === undefined ? 2 : options.logLevel; | ||
@@ -223,2 +230,3 @@ var openPath = (options.open === undefined || options.open === true) ? | ||
ignoreHiddenFiles: true, | ||
ignoreCustomPatterns: options.ignorePattern || null, | ||
preferredMethods: [ 'watchFile', 'watch' ], | ||
@@ -236,7 +244,7 @@ interval: 1407, | ||
if (logLevel >= 1) | ||
console.log("CSS change detected".magenta); | ||
console.log("CSS change detected".magenta, filePath); | ||
} else { | ||
ws.send('reload'); | ||
if (logLevel >= 1) | ||
console.log("File change detected".cyan); | ||
console.log("File change detected".cyan, filePath); | ||
} | ||
@@ -243,0 +251,0 @@ }); |
@@ -43,2 +43,7 @@ #!/usr/bin/env node | ||
} | ||
else if (arg.indexOf("--watch=") > -1) { | ||
// Will be modified later when cwd is known | ||
opts.watch = arg.substring(8).split(","); | ||
process.argv.splice(i, 1); | ||
} | ||
else if (arg.indexOf("--ignore=") > -1) { | ||
@@ -49,2 +54,6 @@ // Will be modified later when cwd is known | ||
} | ||
else if (arg.indexOf("--ignorePattern=") > -1) { | ||
opts.ignorePattern = new RegExp(arg.substring(16)); | ||
process.argv.splice(i, 1); | ||
} | ||
else if (arg == "--no-browser") { | ||
@@ -90,3 +99,3 @@ opts.open = false; | ||
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] [--entry-file=PATH] [--mount=ROUTE:PATH] [--wait=MILLISECONDS] [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] [--entry-file=PATH] [--mount=ROUTE:PATH] [--wait=MILLISECONDS] [PATH]'); | ||
process.exit(); | ||
@@ -105,4 +114,10 @@ } | ||
if (opts.ignore) { // Patch ignore paths | ||
var cwd = process.cwd(); | ||
// Patch paths | ||
var cwd = process.cwd(); | ||
if (opts.watch) { | ||
opts.watch = opts.watch.map(function(relativePath) { | ||
return path.join(cwd, relativePath); | ||
}); | ||
} | ||
if (opts.ignore) { | ||
opts.ignore = opts.ignore.map(function(relativePath) { | ||
@@ -109,0 +124,0 @@ return path.join(cwd, relativePath); |
{ | ||
"name": "live-server", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"description": "simple development http server with live reload capability", | ||
@@ -29,4 +29,4 @@ "keywords": [ | ||
"scripts": { | ||
"test": "mocha test", | ||
"lint": "jshint *.js; eslint *.js" | ||
"lint": "jshint *.js; eslint *.js", | ||
"test": "npm run lint && mocha test" | ||
}, | ||
@@ -33,0 +33,0 @@ "bin": { |
@@ -41,3 +41,3 @@ [![view on npm](http://img.shields.io/npm/v/live-server.svg)](https://www.npmjs.org/package/live-server) | ||
This will automatically launch the default browser (you should have `index.html` present). When you make a change to any file, the browser will reload the page - unless it was a CSS file in which case the changes are applied without a reload. | ||
This will automatically launch the default browser. When you make a change to any file, the browser will reload the page - unless it was a CSS file in which case the changes are applied without a reload. | ||
@@ -52,3 +52,5 @@ Command line parameters: | ||
* `--open=PATH` - launch browser to PATH instead of server root | ||
* `--watch=PATH` - comma-separated string of paths to exclusively watch for changes (default: watch everything) | ||
* `--ignore=PATH` - comma-separated string of paths to ignore | ||
* `--ignorePattern=RGXP` - Regular expression of files to ignore (ie `.*\.jade`) | ||
* `--entry-file=PATH` - serve this file in place of missing files (useful for single page apps) | ||
@@ -94,3 +96,3 @@ * `--mount=ROUTE:PATH` - serve the paths contents under the defined route (multiple definitions possible) | ||
The server is a simple node app that serves the working directory and its subdirectories. It also watches the files for changes and when that happens, it sends a message through a web socket connection to the browser instructing it to reload. In order for the client side to support this, the server injects a small piece of JavaScript code to each requested html file. This script establishes the web socket connection and listens to the reload requests. | ||
The server is a simple node app that serves the working directory and its subdirectories. It also watches the files for changes and when that happens, it sends a message through a web socket connection to the browser instructing it to reload. In order for the client side to support this, the server injects a small piece of JavaScript code to each requested html file. This script establishes the web socket connection and listens to the reload requests. CSS files can be refreshed without a full page reload by finding the referenced stylesheets from the DOM and tricking the browser to fetch and parse them again. | ||
@@ -107,2 +109,5 @@ | ||
* v0.9.1 | ||
- `--ignorePattern=RGXP` exclude files from watching by regexp (@psi-4ward) | ||
- `--watch=PATH` cli option to only watch given paths | ||
* v0.9.0 | ||
@@ -109,0 +114,0 @@ - `--mount=ROUTE:PATH` cli option to specify alternative routes to paths (@pmentz) |
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
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
28542
471
190