coc-live-server 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/lib/index.js +15 -2
- package/package.json +16 -1
- package/index.html +0 -9
package/README.md
CHANGED
|
@@ -12,7 +12,10 @@ Launch a development local Server with live reload feature for static & dynamic
|
|
|
12
12
|
## Configuration options
|
|
13
13
|
|
|
14
14
|
- `coc-live-server.enabled`: Enable coc-live-server extension, default: `true`
|
|
15
|
-
- `coc-live-server.
|
|
15
|
+
- `coc-live-server.host`: server host, default: `0.0.0.0`
|
|
16
|
+
- `coc-live-server.port`: server port, default: `8080`
|
|
17
|
+
- `coc-live-server.cors`: cors, default: `false`
|
|
18
|
+
- `coc-live-server.index`: index file, default: `index.html`
|
|
16
19
|
|
|
17
20
|
## Commands
|
|
18
21
|
|
package/lib/index.js
CHANGED
|
@@ -54,6 +54,10 @@ var statusItem = null;
|
|
|
54
54
|
function startLiveServer() {
|
|
55
55
|
const serverModule = require.resolve("live-server/live-server");
|
|
56
56
|
const port = getConfigItem("port", 8080);
|
|
57
|
+
const host = getConfigItem("host", "0.0.0.0");
|
|
58
|
+
const cors = getConfigItem("cors");
|
|
59
|
+
const index = getConfigItem("index", "index.html");
|
|
60
|
+
const STATUS = `liveServer[:${port}]`;
|
|
57
61
|
const args = [];
|
|
58
62
|
if (liveServerProcess) {
|
|
59
63
|
stopLiveServer(false);
|
|
@@ -64,12 +68,21 @@ function startLiveServer() {
|
|
|
64
68
|
if (port && typeof port === "number") {
|
|
65
69
|
args.push(" --port=" + port);
|
|
66
70
|
}
|
|
71
|
+
if (host && typeof host === "string") {
|
|
72
|
+
args.push(" --host=" + host);
|
|
73
|
+
}
|
|
74
|
+
if (cors) {
|
|
75
|
+
args.push(" --cors");
|
|
76
|
+
}
|
|
77
|
+
if (index && typeof index === "string") {
|
|
78
|
+
args.push(" --index=" + index);
|
|
79
|
+
}
|
|
67
80
|
args.push(` ${import_coc2.workspace.root}`);
|
|
68
81
|
liveServerProcess = (0, import_child_process.spawn)("node", [serverModule, ...args], { shell: true });
|
|
69
82
|
if (liveServerProcess) {
|
|
70
83
|
liveServerProcess.stdout.on("data", (data) => {
|
|
71
|
-
if (statusItem && statusItem?.text !==
|
|
72
|
-
statusItem.text =
|
|
84
|
+
if (statusItem && statusItem?.text !== STATUS) {
|
|
85
|
+
statusItem.text = STATUS;
|
|
73
86
|
}
|
|
74
87
|
const output = data.toString();
|
|
75
88
|
const ansiRegex = /\x1b\[[0-9;]*m/g;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coc-live-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Launch a development local Server with live reload feature for static & dynamic pages.",
|
|
5
5
|
"author": "cyl <a1008611abcd@126.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,10 +36,25 @@
|
|
|
36
36
|
"default": true,
|
|
37
37
|
"description": "Enable coc-live-server extension"
|
|
38
38
|
},
|
|
39
|
+
"coc-live-server.host": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"default": "0.0.0.0",
|
|
42
|
+
"description": "Host for the live server"
|
|
43
|
+
},
|
|
39
44
|
"coc-live-server.port": {
|
|
40
45
|
"type": "number",
|
|
41
46
|
"default": 8080,
|
|
42
47
|
"description": "Port number for the live server"
|
|
48
|
+
},
|
|
49
|
+
"coc-live-server.cors": {
|
|
50
|
+
"type": "boolean",
|
|
51
|
+
"default": false,
|
|
52
|
+
"description": "Enable CORS for the live server"
|
|
53
|
+
},
|
|
54
|
+
"coc-live-server.index": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"default": "index.html",
|
|
57
|
+
"description": "Default file to serve when accessing the root URL"
|
|
43
58
|
}
|
|
44
59
|
}
|
|
45
60
|
},
|