mdbrowse-cli 0.1.1 → 0.2.0
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/bin/mdbrowse-cli.js +17 -4
- package/package.json +1 -1
package/bin/mdbrowse-cli.js
CHANGED
|
@@ -11,7 +11,7 @@ program
|
|
|
11
11
|
.version('0.1.0')
|
|
12
12
|
.argument('[directory]', 'Directory to serve', '.')
|
|
13
13
|
.option('-p, --port <number>', 'Port to listen on', '3000')
|
|
14
|
-
.option('--host <address>', 'Host to bind to', '
|
|
14
|
+
.option('--host <address>', 'Host to bind to', '0.0.0.0')
|
|
15
15
|
.option('--no-ignore', 'Show all files (ignore .gitignore)')
|
|
16
16
|
.option('--auth <credentials>', 'Require basic auth (user:pass)')
|
|
17
17
|
.option('--read-only', 'Disable file editing')
|
|
@@ -41,9 +41,22 @@ program
|
|
|
41
41
|
readOnly,
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
const
|
|
44
|
+
const localUrl = `http://localhost:${actualPort}`;
|
|
45
45
|
console.log(`\n mdbrowse-cli serving ${directory}`);
|
|
46
|
-
console.log(` → ${
|
|
46
|
+
console.log(` → Local: ${localUrl}`);
|
|
47
|
+
|
|
48
|
+
if (host === '0.0.0.0') {
|
|
49
|
+
const { networkInterfaces } = await import('os');
|
|
50
|
+
const nets = networkInterfaces();
|
|
51
|
+
for (const name of Object.keys(nets)) {
|
|
52
|
+
for (const net of nets[name]) {
|
|
53
|
+
if (net.family === 'IPv4' && !net.internal) {
|
|
54
|
+
console.log(` → Network: http://${net.address}:${actualPort}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
console.log();
|
|
47
60
|
|
|
48
61
|
if (options.tunnel) {
|
|
49
62
|
const { startTunnel, registerCleanup } = await import('../src/tunnel.js');
|
|
@@ -73,7 +86,7 @@ program
|
|
|
73
86
|
: process.platform === 'win32'
|
|
74
87
|
? 'start'
|
|
75
88
|
: 'xdg-open';
|
|
76
|
-
exec(`${cmd} ${
|
|
89
|
+
exec(`${cmd} ${localUrl}`);
|
|
77
90
|
}
|
|
78
91
|
});
|
|
79
92
|
|