basic sapper dev task, with HMR

This commit is contained in:
Rich Harris
2018-02-17 17:44:57 -05:00
parent d95f52f8e9
commit ab1ca60363
9 changed files with 248 additions and 179 deletions

18
src/cli/utils.ts Normal file
View File

@@ -0,0 +1,18 @@
import * as net from 'net';
export function wait_for_port(port: number, cb: () => void) {
const socket = net.createConnection({ port }, () => {
cb();
socket.destroy();
});
socket.on('error', err => {
setTimeout(() => {
wait_for_port(port, cb);
}, 100);
});
setTimeout(() => {
socket.destroy();
}, 100);
}