1 | /**
|
2 | * 获取指定文件的相关信息
|
3 | *
|
4 | * @param {string} filePath
|
5 | * @returns
|
6 | *
|
7 | * @memberOf Watch
|
8 | */
|
9 | module.exports = (filePath)=>{
|
10 | const os = require('os');
|
11 | let networkInfo = os.networkInterfaces(),
|
12 | ip;
|
13 | for(let i in networkInfo){
|
14 | let t = networkInfo[i].some((item,index)=>{
|
15 | if(item.family === 'IPv4' && item.address !== '127.0.0.1' && item.address !== '0.0.0.0'){
|
16 | ip = item.address;
|
17 | return true;;
|
18 | };
|
19 | });
|
20 | if(t){
|
21 | break;
|
22 | };
|
23 | };
|
24 | return ip ? ip : 'localhost';
|
25 | }; |
\ | No newline at end of file |