live-dev-server
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -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 @@ }, |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9390
6
250
2