Skip to content

Commit 8aa8ef7

Browse files
oxlint
1 parent 36ab4fc commit 8aa8ef7

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

app/utils/local/microservices.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import { executablePath } from "./path.js";
1515

1616
const MILLISECONDS_PER_SECOND = 1000;
1717
const DEFAULT_TIMEOUT_SECONDS = 30;
18-
const MAX_ERROR_BUFFER_BYTES = 64 * 1024;
18+
const BYTES_PER_KIBIBYTE = 1024;
19+
const MAX_ERROR_BUFFER_KIBIBYTES = 64;
20+
const MAX_ERROR_BUFFER_BYTES = MAX_ERROR_BUFFER_KIBIBYTES * BYTES_PER_KIBIBYTE;
1921

2022
function getAvailablePort() {
2123
return getPort({

app/utils/local/scripts.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import readline from "node:readline";
66

77
import { appMode } from "./app_mode.js";
88

9-
const MAX_ERROR_BUFFER_BYTES = 64 * 1024;
9+
const BYTES_PER_KIBIBYTE = 1024;
10+
const MAX_ERROR_BUFFER_KIBIBYTES = 64;
11+
const MAX_ERROR_BUFFER_BYTES = MAX_ERROR_BUFFER_KIBIBYTES * BYTES_PER_KIBIBYTE;
1012

1113
function commandExistsSync(execName) {
1214
const envPath = process.env.PATH || "";
13-
return envPath.split(path.delimiter).some((dir) => {
14-
const filePath = path.join(dir, execName);
15+
return envPath.split(path.delimiter).some((directory) => {
16+
const filePath = path.join(directory, execName);
1517
return fs.existsSync(filePath) && fs.statSync(filePath).isFile();
1618
});
1719
}
@@ -22,18 +24,18 @@ function waitForReady(child, expectedResponse, signal) {
2224
const readlineStderr = readline.createInterface({ input: child.stderr });
2325

2426
let recentOutput = "";
25-
const recordOutput = (line) => {
27+
function recordOutput(line) {
2628
recentOutput = (recentOutput + line + "\n").slice(-MAX_ERROR_BUFFER_BYTES);
2729
};
2830

29-
const cleanup = () => {
31+
function cleanup() {
3032
readlineStdout.removeAllListeners();
3133
readlineStdout.close();
3234
readlineStderr.removeAllListeners();
3335
readlineStderr.close();
3436
child.removeListener("error", onError);
3537
child.removeListener("close", onClose);
36-
if (signal) signal.removeEventListener("abort", onAbort);
38+
if (signal) { signal.removeEventListener("abort", onAbort); }
3739
};
3840

3941
const onLine = (line) => {
@@ -45,17 +47,17 @@ function waitForReady(child, expectedResponse, signal) {
4547
}
4648
};
4749

48-
const onErrLine = (line) => {
50+
function onErrLine(line) {
4951
console.log(`[${child.name}] ${line}`);
5052
recordOutput(line);
5153
};
5254

53-
const onError = (err) => {
55+
function onError(err) {
5456
cleanup();
5557
reject(err);
5658
};
5759

58-
const onClose = (code) => {
60+
function onClose(code) {
5961
console.log(`[${child.name}] exited with code ${code}`);
6062
cleanup();
6163
reject(
@@ -66,7 +68,7 @@ function waitForReady(child, expectedResponse, signal) {
6668
);
6769
};
6870

69-
const onAbort = () => {
71+
function onAbort() {
7072
cleanup();
7173
reject(new Error(`[${child.name}] timed out waiting for "${expectedResponse}"`));
7274
};
@@ -75,7 +77,7 @@ function waitForReady(child, expectedResponse, signal) {
7577
readlineStderr.on("line", onErrLine);
7678
child.once("error", onError);
7779
child.once("close", onClose);
78-
if (signal) signal.addEventListener("abort", onAbort, { once: true });
80+
if (signal) { signal.addEventListener("abort", onAbort, { once: true }); }
7981
})
8082
}
8183

0 commit comments

Comments
 (0)