Socket
Socket
Sign inDemoInstall

live-server

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

live-server - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

injected.html

20

live-server.js

@@ -13,2 +13,4 @@ #!/usr/bin/env node

var INJECTED_CODE = require('fs').readFileSync(__dirname + "/injected.html", "utf8");
function escape(html){

@@ -43,14 +45,7 @@ return String(html)

if (x == "" || x == ".html" || x == ".htm" || x == ".xhtml" || x == ".php") {
var code = "<script>\n(function() {\n" +
"protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://';\n" +
"address = protocol + window.location.host + window.location.pathname + '/ws';\n" +
"socket = new WebSocket(address);\n" +
"socket.onmessage = function(msg) { msg.data == 'reload' && window.location.reload() };\n" +
"console.log('Live reload enabled.');\n" +
"})();\n</script>";
// We need to modify the length given to browser
var len = code.length + res.getHeader('Content-Length');
var len = INJECTED_CODE.length + res.getHeader('Content-Length');
res.setHeader('Content-Length', len);
// Write the injected code
res.write(code);
res.write(INJECTED_CODE);
}

@@ -85,4 +80,7 @@ }

ignorePatterns: true,
listener: function(eventName, filePath, fileCurrentStat, filePreviousStat){
ws && ws.send('reload');
ignoreHiddenFiles: true,
listener: function(eventName, filePath, fileCurrentStat, filePreviousStat) {
if (!ws) return;
if (path.extname(filePath) == ".css") ws.send('refreshcss');
else ws.send('reload');
}

@@ -89,0 +87,0 @@ });

{
"name": "live-server",
"version": "0.1.1",
"version": "0.2.0",
"description": "simple development http server with live reload capability",

@@ -5,0 +5,0 @@ "keywords": [

@@ -38,3 +38,3 @@ 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.
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.

@@ -41,0 +41,0 @@ You can configure the port to be used by setting `PORT` environment variable prior to launching the server.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc