Skip to content

Commit

Permalink
add check for mac (ofc mac has to break something lol)
Browse files Browse the repository at this point in the history
  • Loading branch information
thatgurkangurk committed Oct 24, 2023
1 parent d3d7159 commit 859d85f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions bin/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { logBuildPlugin } from "../src/util.mjs";
import { sassPlugin } from "esbuild-sass-plugin";
import { fileURLToPath } from "url";
import { AddonType, getAddonFolder, isMonoRepo, selectAddon } from "./mono.mjs";
import { hostname } from "os";
import { hostname, platform } from "os";

interface BaseArgs {
watch?: boolean;
Expand Down Expand Up @@ -67,11 +67,19 @@ let ws: WebSocket | undefined;
let failed = false;
let connectingPromise: Promise<WebSocket | undefined> | undefined;

function isMac(): boolean {
return platform() === "darwin";
}

/**
* Try to connect to RPC on a specific port and handle the READY event as well as errors and close events
*/
function tryPort(port: number): Promise<WebSocket | undefined> {
ws = new WebSocket(`ws://${hostname()}.local:${port}/?v=1&client_id=REPLUGGED-${random()}`);
ws = new WebSocket(
`ws://${
isMac() ? "localhost" : `${hostname()}.local`
}:${port}/?v=1&client_id=REPLUGGED-${random()}`,
);
return new Promise((resolve, reject) => {
let didFinish = false;
ws?.on("message", (data) => {
Expand Down

0 comments on commit 859d85f

Please sign in to comment.