CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-external-editor

Edit a string with the users preferred text editor using $VISUAL or $ENVIRONMENT

79

1.05x
Overview
Eval results
Files

task.mdevals/scenario-5/

Editor Exit Reporter

Captures text from a user-invoked external editor, returning both the saved content and the editor's exit status without treating non-zero exits as fatal.

Capabilities

Captures edited text

  • Given initial text "Draft note" the function resolves with the updated content after the user saves, returning exitStatus 0. @test

Returns empty saves

  • When the user saves an empty file, the function resolves with an empty string and exitStatus 0 rather than substituting defaults or throwing. @test

Surfaces non-zero exit

  • If the editor process ends with exit code 1 after the user saves "keep me", the function resolves without throwing, returning that content and exitStatus 1. @test

Implementation

@generates

The returned exitStatus should mirror the editor process exit code; use null only when no code is available.

API

export interface EditorResult {
  text: string;
  exitStatus: number | null;
}

export interface EditorOptions {
  initialText?: string;
}

export function runEditorSession(options?: EditorOptions): Promise<EditorResult>;

Dependencies { .dependencies }

external-editor { .dependency }

Launches the user's preferred text editor and captures edited file contents.

Install with Tessl CLI

npx tessl i tessl/npm-external-editor

tile.json