()
| 89 | } |
| 90 | |
| 91 | start() { |
| 92 | this.tree = FSTree.fromEntries([]); |
| 93 | // Reload on file changes |
| 94 | this.watcher.on( |
| 95 | 'change', |
| 96 | function () { |
| 97 | try { |
| 98 | this.didChange.apply(this, arguments); |
| 99 | } catch (e) { |
| 100 | this.ui.writeError(e); |
| 101 | } |
| 102 | }.bind(this) |
| 103 | ); |
| 104 | |
| 105 | this.watcher.on('error', this.didChange.bind(this)); |
| 106 | |
| 107 | // Reload on express server restarts |
| 108 | this.app.on('restart', this.didRestart.bind(this)); |
| 109 | this.httpServer.on('upgrade', (req, socket, head) => { |
| 110 | if (isLiveReloadRequest(req.url, this.liveReloadPrefix)) { |
| 111 | this.liveReloadServer.websocketify(req, socket, head); |
| 112 | } |
| 113 | }); |
| 114 | this.httpServer.on('error', this.liveReloadServer.error.bind(this.liveReloadServer)); |
| 115 | this.httpServer.on('close', this.liveReloadServer.close.bind(this.liveReloadServer)); |
| 116 | this.app.use(this.liveReloadPrefix, this.liveReloadServer.handler.bind(this.liveReloadServer)); |
| 117 | } |
| 118 | |
| 119 | createServer(options, Server) { |
| 120 | let serverOptions = { |
no test coverage detected