function openInEditor
openInEditor(
file: string,
line: number,
server: REPLServer,
named?: string
): Promise<{ failed: string | null; saved: boolean; }>

Opens a file at a line in the developer's editor, or says why it could not.

+LINE file is the argument every terminal editor since vi has taken, and the ones that do not ignore it and open the file anyway — which is still the thing that was asked for.

failed is the line to print when it could not run: no $EDITOR set, or one that is not there. saved says whether the editor WROTE it, which is how a caller knows a file the session had in scope has moved out from under it. named is for the commands named after an editor, which mean that one rather than whichever the environment prefers.

import { openInEditor } from './editor.ts';

import type { REPLServer } from 'node:repl';

// Defined, not invoked: it hands a real terminal to a real editor.
function example(server: REPLServer) {
  return openInEditor('/proj/a.ts', 12, server); // { failed: null, saved: boolean }
}

Parameters

file: string
line: number
server: REPLServer
optional
named: string

Return Type

Promise<{ failed: string | null; saved: boolean; }>

Usage

import { openInEditor } from "lib/commands/repl/editor.ts";