@effectstream/utils 0.100.6 → 0.100.8
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/package.json +2 -4
- package/src/wait-http.ts +0 -24
- package/src/wait-tcp.ts +0 -30
package/package.json
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effectstream/utils",
|
|
3
|
-
"version": "0.100.
|
|
3
|
+
"version": "0.100.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./src/mod.ts",
|
|
7
7
|
"./node-env": "./src/config.ts",
|
|
8
8
|
"./runtime": "./src/runtime.ts",
|
|
9
|
-
"./runtime-spawn": "./src/runtime-spawn.ts"
|
|
10
|
-
"./wait-tcp": "./src/wait-tcp.ts",
|
|
11
|
-
"./wait-http": "./src/wait-http.ts"
|
|
9
|
+
"./runtime-spawn": "./src/runtime-spawn.ts"
|
|
12
10
|
},
|
|
13
11
|
"dependencies": {
|
|
14
12
|
"@coderspirit/nominal": "^4.1.1",
|
package/src/wait-http.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const url = process.argv.at(-1);
|
|
2
|
-
if (!url || !url.startsWith("http")) {
|
|
3
|
-
console.error("Usage: bun wait-http.ts <url>");
|
|
4
|
-
process.exit(1);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const timeout = Number(process.argv.includes("--timeout")
|
|
8
|
-
? process.argv[process.argv.indexOf("--timeout") + 1]
|
|
9
|
-
: 60000);
|
|
10
|
-
|
|
11
|
-
const start = Date.now();
|
|
12
|
-
|
|
13
|
-
while (Date.now() - start < timeout) {
|
|
14
|
-
try {
|
|
15
|
-
const res = await fetch(url);
|
|
16
|
-
if (res.ok) process.exit(0);
|
|
17
|
-
} catch {
|
|
18
|
-
// not ready yet
|
|
19
|
-
}
|
|
20
|
-
await Bun.sleep(500);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
console.error(`Timed out waiting for ${url}`);
|
|
24
|
-
process.exit(1);
|
package/src/wait-tcp.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const port = Number(process.argv.at(-1));
|
|
2
|
-
if (!port || isNaN(port)) {
|
|
3
|
-
console.error("Usage: bun wait-tcp.ts <port>");
|
|
4
|
-
process.exit(1);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
for (let i = 0; i < 120; i++) {
|
|
8
|
-
try {
|
|
9
|
-
const connected = await new Promise<boolean>((resolve) => {
|
|
10
|
-
Bun.connect({
|
|
11
|
-
hostname: "127.0.0.1",
|
|
12
|
-
port,
|
|
13
|
-
socket: {
|
|
14
|
-
open(socket) { socket.end(); resolve(true); },
|
|
15
|
-
data() {},
|
|
16
|
-
error() { resolve(false); },
|
|
17
|
-
close() {},
|
|
18
|
-
connectError() { resolve(false); },
|
|
19
|
-
},
|
|
20
|
-
}).catch(() => resolve(false));
|
|
21
|
-
});
|
|
22
|
-
if (connected) process.exit(0);
|
|
23
|
-
} catch {
|
|
24
|
-
// fallthrough to retry
|
|
25
|
-
}
|
|
26
|
-
await Bun.sleep(500);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
console.error(`Timed out waiting for tcp:${port}`);
|
|
30
|
-
process.exit(1);
|