Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

live-dev-server

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

live-dev-server - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

example/package.json

21

lib/index.js

@@ -56,5 +56,5 @@ const http = require('http')

let edata = event.data
if (edata.indexOf('sign') < 0) return
if (edata.indexOf('origin') < 0) return
let data = JSON.parse(edata)
if (data.sign == 'reload') {
if (data.origin == 'watcher') {
window.location.reload()

@@ -226,3 +226,3 @@ }

clients.forEach((ws) => {
ws.send(generateWatchMessage('reload', path))
ws.send(generateWatchMessage('watcher', path))
})

@@ -249,8 +249,8 @@ })

* generate send message
* @param {String} sign ws send type, reload...
* @param {String} origin ws send from
* @param {Object} data send data
*/
function generateMessage(sign, data) {
function generateMessage(origin, data) {
return JSON.stringify({
sign,
origin,
data,

@@ -262,7 +262,10 @@ })

* watch file change, generate send message
* @param {String} sign type
* @param {String} origin type
* @param {String} path file path
*/
function generateWatchMessage(sign, path) {
return generateMessage(sign, { path, host: openURL })
function generateWatchMessage(origin, filePath) {
console.log(projectRoot, filePath)
let pathname = filePath.replace(projectRoot, '')
let fileExt = pathname.split('.')[1] || 'unknown'
return generateMessage(origin, { url: path.join(openURL, pathname), host: openURL, pathname, ext: fileExt })
}

@@ -269,0 +272,0 @@

{
"name": "live-dev-server",
"version": "0.6.0",
"version": "0.7.0",
"description": "develop env, watch files change, mock data",

@@ -10,3 +10,3 @@ "main": "lib/index.js",

"scripts": {
"serve": "node index.js",
"serve": "node lib/index.js",
"test": "echo \"Error: no test specified\" && exit 1"

@@ -13,0 +13,0 @@ },

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