Skip to content

Commit 3f8d1d7

Browse files
committed
chore(controller): fix lint errors
1 parent 9a48fb8 commit 3f8d1d7

File tree

5 files changed

+43
-43
lines changed

5 files changed

+43
-43
lines changed

packages/controller/src/ipc/__tests__/ipc-client.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ describe("IPCClient", () => {
8585
const result = await client.connect("/test/socket");
8686

8787
expect(result.isOk()).toBe(true);
88-
expect(net.createConnection).toHaveBeenCalledWith(getOSSocketPath("/test/socket"), expect.any(Function));
88+
expect(net.createConnection).toHaveBeenCalledWith(
89+
getOSSocketPath("/test/socket"),
90+
expect.any(Function),
91+
);
8992
});
9093

9194
it("should return error if connection fails", async () => {

packages/controller/src/ipc/__tests__/ipc-utils.test.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ import { describe, expect, it } from "vitest";
22
import { getOSSocketPath } from "../ipc-utils.js";
33

44
describe("getOSSocketPath", () => {
5-
describe.runIf(process.platform !== "win32")("on posix", () => {
6-
it("returns the same path", () => {
7-
const inputPath = "/tmp/socket.sock";
8-
const result = getOSSocketPath(inputPath);
9-
expect(result).toBe(inputPath);
10-
});
11-
});
5+
describe.runIf(process.platform !== "win32")("on posix", () => {
6+
it("returns the same path", () => {
7+
const inputPath = "/tmp/socket.sock";
8+
const result = getOSSocketPath(inputPath);
9+
expect(result).toBe(inputPath);
10+
});
11+
});
1212

13-
describe.runIf(process.platform === "win32")("on Windows", () => {
14-
it('updates the path to use named pipe format if not already in that format', () => {
15-
const inputPath = "C:\\temp\\socket.sock";
16-
const expectedPath = "\\\\?\\pipe\\C:\\temp\\socket.sock";
17-
const result = getOSSocketPath(inputPath);
18-
expect(result).toBe(expectedPath);
19-
});
13+
describe.runIf(process.platform === "win32")("on Windows", () => {
14+
it("updates the path to use named pipe format if not already in that format", () => {
15+
const inputPath = "C:\\temp\\socket.sock";
16+
const expectedPath = "\\\\?\\pipe\\C:\\temp\\socket.sock";
17+
const result = getOSSocketPath(inputPath);
18+
expect(result).toBe(expectedPath);
19+
});
2020

21-
it('returns the same path if already in named pipe format with \\\\?\\pipe prefix', () => {
22-
const inputPath = "\\\\?\\pipe\\my_named_pipe";
23-
const result = getOSSocketPath(inputPath);
24-
expect(result).toBe(inputPath);
25-
});
26-
});
27-
})
21+
it("returns the same path if already in named pipe format with \\\\?\\pipe prefix", () => {
22+
const inputPath = "\\\\?\\pipe\\my_named_pipe";
23+
const result = getOSSocketPath(inputPath);
24+
expect(result).toBe(inputPath);
25+
});
26+
});
27+
});

packages/controller/src/ipc/ipc-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export class IPCClient {
232232
try {
233233
this._lastState = applyPatches(this._lastState, patches);
234234
this._lastStateVersion = version;
235-
} catch (e) {
235+
} catch (_e) {
236236
return errAsync(new IPCMessageError("Failed to apply patches"));
237237
}
238238

packages/controller/src/ipc/ipc-utils.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@ import path from "node:path";
55
* https://nodejs.org/api/net.html#identifying-paths-for-ipc-connections
66
*/
77
export function getOSSocketPath(socketPath: string) {
8-
if (process.platform === "win32") {
9-
// On Windows, we need to use a named pipe
8+
if (process.platform === "win32") {
9+
// On Windows, we need to use a named pipe
1010

11-
if (socketPath.includes("\\\\?\\pipe") || socketPath.includes("\\\\.\\pipe")) {
12-
// Already in correct format
13-
return socketPath;
14-
}
15-
return path.join(
16-
'\\\\?\\pipe',
17-
socketPath
18-
)
19-
}
20-
return socketPath;
21-
}
11+
if (socketPath.includes("\\\\?\\pipe") || socketPath.includes("\\\\.\\pipe")) {
12+
// Already in correct format
13+
return socketPath;
14+
}
15+
return path.join("\\\\?\\pipe", socketPath);
16+
}
17+
return socketPath;
18+
}

packages/controller/src/transports/ipc-transport.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import fs from "node:fs";
77
import net from "node:net";
88
import path from "node:path";
99
import type { LaunchpadEvents } from "@bluecadet/launchpad-utils";
10+
import chalk from "chalk";
1011
import type { Patch } from "immer";
1112
import { ResultAsync } from "neverthrow";
1213
import type { VersionedLaunchpadState } from "../core/state-store.js";
1314
import type { Transport, TransportContext } from "../core/transport.js";
14-
import chalk from 'chalk'
1515
import {
1616
CommandExecutionError,
1717
IPCMessageError,
@@ -64,16 +64,16 @@ export function createIPCTransport(options: IPCTransportOptions): Transport {
6464
start(ctx: TransportContext): ResultAsync<void, TransportError> {
6565
const { logger, abortSignal } = ctx;
6666

67-
if (process.platform == "win32" && (options.socketPath !== socketPath)) {
67+
if (process.platform === "win32" && options.socketPath !== socketPath) {
6868
// notify user that the socket path has been updated to conform with windows named pipe reqs,
6969
// as it might not be where they expect it
7070

7171
logger.warn(
72-
`Windows named pipes must be located in ${chalk.grey("\\\\?\\pipe\\")} or ${chalk.grey("\\\\.\\pipe\\")}. `
73-
)
72+
`Windows named pipes must be located in ${chalk.grey("\\\\?\\pipe\\")} or ${chalk.grey("\\\\.\\pipe\\")}. `,
73+
);
7474
logger.warn(
75-
`The configured socketPath has been moved to the ${chalk.grey("\\\\?\\pipe\\")} directory to conform with this requirement.`
76-
)
75+
`The configured socketPath has been moved to the ${chalk.grey("\\\\?\\pipe\\")} directory to conform with this requirement.`,
76+
);
7777
}
7878

7979
const promise = new Promise<void>((resolve, reject) => {
@@ -385,4 +385,4 @@ function sendError(socket: net.Socket, id: string, error: Error): void {
385385
type: "error",
386386
error: error,
387387
});
388-
}
388+
}

0 commit comments

Comments
 (0)