@open-mercato/cli 0.6.5-develop.4718.1.56d834bb34 → 0.6.5-develop.4734.1.dd8285dd2e
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/lib/testing/integration.js +16 -8
- package/dist/lib/testing/integration.js.map +2 -2
- package/dist/lib/testing/runtime-utils.js +16 -8
- package/dist/lib/testing/runtime-utils.js.map +2 -2
- package/package.json +5 -5
- package/src/lib/testing/__tests__/runtime-utils.test.ts +45 -1
- package/src/lib/testing/integration.ts +17 -8
- package/src/lib/testing/runtime-utils.ts +17 -8
|
@@ -753,10 +753,17 @@ async function shouldRebuildBuildArtifacts(ttlSeconds, logPrefix, options = {})
|
|
|
753
753
|
return !await shouldReuseBuildArtifacts(ttlSeconds, logPrefix, options);
|
|
754
754
|
}
|
|
755
755
|
async function getFreePort() {
|
|
756
|
-
|
|
756
|
+
const tryListen = (host) => new Promise((resolve, reject) => {
|
|
757
757
|
const server = createServer();
|
|
758
|
-
server.on("error",
|
|
759
|
-
|
|
758
|
+
server.on("error", (error) => {
|
|
759
|
+
const errorCode = error.code;
|
|
760
|
+
if (errorCode === "EAFNOSUPPORT") {
|
|
761
|
+
resolve(null);
|
|
762
|
+
return;
|
|
763
|
+
}
|
|
764
|
+
reject(error);
|
|
765
|
+
});
|
|
766
|
+
server.listen(0, host, () => {
|
|
760
767
|
const address = server.address();
|
|
761
768
|
if (!address || typeof address === "string") {
|
|
762
769
|
server.close();
|
|
@@ -773,6 +780,7 @@ async function getFreePort() {
|
|
|
773
780
|
});
|
|
774
781
|
});
|
|
775
782
|
});
|
|
783
|
+
return await tryListen("::") ?? await tryListen("127.0.0.1") ?? Promise.reject(new Error("Unable to allocate free port"));
|
|
776
784
|
}
|
|
777
785
|
async function isPortAvailable(port) {
|
|
778
786
|
const canBind = (host) => new Promise((resolve) => {
|
|
@@ -791,15 +799,15 @@ async function isPortAvailable(port) {
|
|
|
791
799
|
});
|
|
792
800
|
});
|
|
793
801
|
});
|
|
794
|
-
const
|
|
795
|
-
if (
|
|
802
|
+
const wildcardIpv6Availability = await canBind("::");
|
|
803
|
+
if (wildcardIpv6Availability === false) {
|
|
796
804
|
return false;
|
|
797
805
|
}
|
|
798
|
-
const
|
|
799
|
-
if (
|
|
806
|
+
const ipv4Availability = await canBind("127.0.0.1");
|
|
807
|
+
if (ipv4Availability === false) {
|
|
800
808
|
return false;
|
|
801
809
|
}
|
|
802
|
-
return
|
|
810
|
+
return wildcardIpv6Availability === true || ipv4Availability === true;
|
|
803
811
|
}
|
|
804
812
|
async function getPreferredPort(preferredPort) {
|
|
805
813
|
if (await isPortAvailable(preferredPort)) {
|