mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-13 19:45:26 +00:00
basic sapper dev task, with HMR
This commit is contained in:
18
src/cli/utils.ts
Normal file
18
src/cli/utils.ts
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user