Edit a string with the users preferred text editor using $VISUAL or $ENVIRONMENT
79
Provide a thin wrapper around a system text editor so callers can run synchronous or asynchronous editing sessions, read the edited content, observe the editor's exit status, and clean up the temporary file explicitly when needed.
@generates
export interface TempFileOptions {
prefix?: string;
postfix?: string;
template?: string;
dir?: string;
mode?: number;
}
export interface SessionResult {
content: string;
exitStatus: number;
path: string;
}
export class EditorLifecycle {
constructor(initialText?: string, fileOptions?: TempFileOptions);
/**
* Launch the editor synchronously and return edited content with exit status.
*/
launchSync(): SessionResult;
/**
* Launch the editor asynchronously and invoke the callback with content and exit status.
*/
launchAsync(callback: (err: Error | null, result?: SessionResult) => void): void;
/**
* Remove the temporary file even if no launch occurred.
*/
discard(): void;
}Uses an external editor library to manage launching, reading, exit status reporting, and cleanup for the temporary file.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-external-editordocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10