| 57 | } |
| 58 | |
| 59 | async function createServer({port}: { port: number }) { |
| 60 | const foundPort = await portfinder.getPortPromise({port}); |
| 61 | |
| 62 | http.createServer((request, response) => { |
| 63 | response.writeHead(200, {'Content-Type': 'text-plain;charset=utf-8'}); |
| 64 | |
| 65 | response.end(getHosts()); |
| 66 | }).listen(foundPort); |
| 67 | |
| 68 | const localUrl = `http://localhost:${foundPort}`; |
| 69 | |
| 70 | console.log(); |
| 71 | console.log( |
| 72 | [ |
| 73 | ` 当前版本:${pkg.version}`, |
| 74 | ` Github Hosts 运行在:`, |
| 75 | ` - Local: ${chalk.cyan(localUrl)}`, |
| 76 | ].join('\n'), |
| 77 | ); |
| 78 | console.log(); |
| 79 | } |