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

Temp Draft Editor

Utility that opens the user's editor on a temporary draft file whose name, location, and permissions can be customized, then returns the saved text.

Capabilities

Configurable temp naming

  • When called with prefix "draft-" and postfix ".txt", the temporary file name begins with "draft-" and ends with ".txt" before the editor opens. @test
  • When provided dir "/tmp/custom" and template "note-XXXX.log", the created file lives inside "/tmp/custom" and its basename matches the template pattern with characters replacing each X. @test

File permissions and cleanup

  • When a mode of 0o600 is supplied, the temporary file is created with that permission mask and is removed after the editor closes. @test

Edited content surfaced

  • Returns whatever text is saved by the user in the editor, starting from the provided initial content. @test

Implementation

@generates

API

export function openDraft(initialText?: string, options?: {
  prefix?: string;
  postfix?: string;
  dir?: string;
  template?: string;
  mode?: number;
}): { content: string; filePath: string; lastExitStatus: number | null; };

export function openDraftAsync(
  initialText?: string,
  options?: {
    prefix?: string;
    postfix?: string;
    dir?: string;
    template?: string;
    mode?: number;
  },
  callback: (err: Error | null, result?: { content: string; filePath: string; lastExitStatus: number | null; }) => void
): void;

Dependencies { .dependencies }

external-editor { .dependency }

Provides editor-driven workflows backed by configurable temporary files. @satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-external-editor

tile.json