function tryConnect
tryConnect(cwd?: string): Promise<net.Socket | null>

Opens a connection to the daemon for the given cwd. Resolves the connected socket on success; resolves null on any failure (no socket file, ECONNREFUSED, timeout).

import * as Client from './client.ts';

// Defined, not invoked: dials the project's daemon socket.
async function probe() {
  return await Client.tryConnect('/proj'); // net.Socket, or null within 1s on any failure
}

Parameters

optional
cwd: string

Return Type

Promise<net.Socket | null>

Usage

import { tryConnect } from "lib/commands/daemon/client.ts";