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", "sander": "^0.6.0",
"serialize-javascript": "^1.4.0", "serialize-javascript": "^1.4.0",
"url-parse": "^1.2.0", "url-parse": "^1.2.0",
"wait-port": "^0.2.2",
"walk-sync": "^0.3.2", "walk-sync": "^0.3.2",
"webpack": "^3.10.0" "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) { export function wait_for_port(port: number, cb: () => void) {
const socket = net.createConnection({ port }, () => { waitPort({ port }).then(cb);
cb(); }
socket.destroy();
});
socket.on('error', err => { // import * as net from 'net';
setTimeout(() => {
wait_for_port(port, cb);
}, 100);
});
setTimeout(() => { // export function wait_for_port(port: number, cb: () => void) {
socket.destroy(); // const socket = net.createConnection(port, 'localhost', () => {
}, 100); // cb();
} // socket.destroy();
// });
// socket.on('error', err => {
// setTimeout(() => {
// wait_for_port(port, cb);
// }, 100);
// });
// setTimeout(() => {
// socket.destroy();
// }, 100);
// }