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-7/

Editor Exit Session

A utility that opens the user's editor on a temporary file and reports both the edited content and the editor process exit code.

Capabilities

Capture exit status on successful edit

  • Starting with text "hello", after the user saves without changes and exits normally, return the same text and an exit status of 0. @test

Surface non-zero exit codes

  • When the editor command exits with code 42 without modifying the file, return the original text and an exit status of 42. @test

Allow custom editor command

  • Given a custom editor command that writes "done" into the file and exits with code 0, return "done" and an exit status of 0. @test

Expose last exit status

  • Before any run, the accessor reports null; after a run it returns the most recent exit status value. @test

Implementation

@generates

API

export type EditorRunOptions = {
  editorCommand?: string;
  initialText?: string;
};

export type EditorRunResult = {
  content: string;
  exitStatus: number | null;
};

export function editOnce(options?: EditorRunOptions): Promise<EditorRunResult>;
export function editOnceSync(options?: EditorRunOptions): EditorRunResult;
export function getLastExitStatus(): number | null;

Dependencies { .dependencies }

external-editor { .dependency }

Provides access to the user's preferred text editor and exposes the process exit status.

Install with Tessl CLI

npx tessl i tessl/npm-external-editor

tile.json