@jsenv/test 3.7.34 → 3.7.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jsenv_test.js +32 -5
- package/package.json +3 -3
package/dist/jsenv_test.js
CHANGED
|
@@ -9581,6 +9581,19 @@ const createWekbitRuntime = (params) => {
|
|
|
9581
9581
|
});
|
|
9582
9582
|
};
|
|
9583
9583
|
|
|
9584
|
+
/**
|
|
9585
|
+
* Find a port nobody listens to on the given hostname, trying `initialPort`
|
|
9586
|
+
* first then the following ones.
|
|
9587
|
+
*
|
|
9588
|
+
* @param {number} [initialPort=1] - First port to try.
|
|
9589
|
+
* @param {Object} [options]
|
|
9590
|
+
* @param {AbortSignal} [options.signal]
|
|
9591
|
+
* @param {string} [options.hostname="127.0.0.1"] - Interface the port must be free on.
|
|
9592
|
+
* @param {number} [options.min=1]
|
|
9593
|
+
* @param {number} [options.max=65534] - Give up (throw) past this port.
|
|
9594
|
+
* @param {(port: number) => number} [options.next] - How to pick the next port to try.
|
|
9595
|
+
* @returns {Promise<number>}
|
|
9596
|
+
*/
|
|
9584
9597
|
const findFreePort = async (
|
|
9585
9598
|
initialPort = 1,
|
|
9586
9599
|
{
|
|
@@ -9643,20 +9656,34 @@ const portIsFree = async (port, hostname) => {
|
|
|
9643
9656
|
|
|
9644
9657
|
const startListening = ({ server, port, hostname }) => {
|
|
9645
9658
|
return new Promise((resolve, reject) => {
|
|
9646
|
-
|
|
9647
|
-
|
|
9659
|
+
const onError = (error) => {
|
|
9660
|
+
server.removeListener("listening", onListening);
|
|
9661
|
+
reject(error);
|
|
9662
|
+
};
|
|
9663
|
+
const onListening = () => {
|
|
9664
|
+
server.removeListener("error", onError);
|
|
9648
9665
|
// in case port is 0 (randomly assign an available port)
|
|
9649
9666
|
// https://nodejs.org/api/net.html#net_server_listen_port_host_backlog_callback
|
|
9650
9667
|
resolve(server.address().port);
|
|
9651
|
-
}
|
|
9668
|
+
};
|
|
9669
|
+
server.once("error", onError);
|
|
9670
|
+
server.once("listening", onListening);
|
|
9652
9671
|
server.listen(port, hostname);
|
|
9653
9672
|
});
|
|
9654
9673
|
};
|
|
9655
9674
|
|
|
9656
9675
|
const stopListening = (server) => {
|
|
9657
9676
|
return new Promise((resolve, reject) => {
|
|
9658
|
-
|
|
9659
|
-
|
|
9677
|
+
const onError = (error) => {
|
|
9678
|
+
server.removeListener("close", onClose);
|
|
9679
|
+
reject(error);
|
|
9680
|
+
};
|
|
9681
|
+
const onClose = () => {
|
|
9682
|
+
server.removeListener("error", onError);
|
|
9683
|
+
resolve();
|
|
9684
|
+
};
|
|
9685
|
+
server.once("error", onError);
|
|
9686
|
+
server.once("close", onClose);
|
|
9660
9687
|
server.close();
|
|
9661
9688
|
});
|
|
9662
9689
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/test",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.35",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@c88/v8-coverage": "0.1.1",
|
|
33
|
-
"@jsenv/ast": "6.9.
|
|
34
|
-
"@jsenv/plugin-supervisor": "1.8.
|
|
33
|
+
"@jsenv/ast": "6.9.3",
|
|
34
|
+
"@jsenv/plugin-supervisor": "1.8.14",
|
|
35
35
|
"@jsenv/sourcemap": "1.4.2",
|
|
36
36
|
"he": "1.2.0",
|
|
37
37
|
"istanbul-lib-coverage": "3.2.2",
|