()
| 49 | }; |
| 50 | |
| 51 | connect() { |
| 52 | const infoFile = getInfoFile(this.shellDir); |
| 53 | |
| 54 | fs.readFile(infoFile, "utf8", (err, json) => { |
| 55 | if (err) { |
| 56 | return this.reconnect(); |
| 57 | } |
| 58 | |
| 59 | let info; |
| 60 | try { |
| 61 | info = JSON.parse(json); |
| 62 | } catch (err) { |
| 63 | return this.reconnect(); |
| 64 | } |
| 65 | |
| 66 | if (info.status !== "enabled") { |
| 67 | if (this.firstTimeConnecting) { |
| 68 | return this.reconnect(); |
| 69 | } |
| 70 | |
| 71 | if (info.reason) { |
| 72 | console.error(info.reason); |
| 73 | } |
| 74 | |
| 75 | console.error(EXITING_MESSAGE); |
| 76 | process.exit(0); |
| 77 | } |
| 78 | |
| 79 | this.setUpSocket( |
| 80 | net.connect(info.port, "127.0.0.1"), |
| 81 | info.key |
| 82 | ); |
| 83 | }); |
| 84 | }; |
| 85 | |
| 86 | setUpSocketForSingleUse(sock: net.Socket, key: string) { |
| 87 | sock.on("connect", function () { |
no test coverage detected