forked from Lumieducation/H5P-Nodejs-library
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.ts
More file actions
24 lines (23 loc) · 848 Bytes
/
Copy pathutils.ts
File metadata and controls
24 lines (23 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os from 'os';
/**
* Displays links to the server at all available IP addresses.
* @param port The port at which the server can be accessed.
*/
export function displayIps(port: string): void {
// tslint:disable-next-line: no-console
console.log('Example H5P NodeJs server is running:');
const networkInterfaces = os.networkInterfaces();
// tslint:disable-next-line: forin
for (const devName in networkInterfaces) {
networkInterfaces[devName]
.filter((int) => !int.internal)
.forEach((int) =>
// tslint:disable-next-line: no-console
console.log(
`http://${int.family === 'IPv6' ? '[' : ''}${int.address}${
int.family === 'IPv6' ? ']' : ''
}:${port}`
)
);
}
}