see if this fixes windows tests

This commit is contained in:
Rich Harris
2018-02-18 08:27:07 -05:00
parent 99d4eafb0b
commit d55401d45b
2 changed files with 21 additions and 14 deletions

View File

@@ -36,6 +36,7 @@
"sander": "^0.6.0",
"serialize-javascript": "^1.4.0",
"url-parse": "^1.2.0",
"wait-port": "^0.2.2",
"walk-sync": "^0.3.2",
"webpack": "^3.10.0"
},

View File

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