[6a3a178] | 1 | /***
|
---|
| 2 | * Node External Editor
|
---|
| 3 | *
|
---|
| 4 | * Kevin Gravier <kevin@mrkmg.com>
|
---|
| 5 | * MIT 2019
|
---|
| 6 | */
|
---|
| 7 | import { CreateFileError } from "./errors/CreateFileError";
|
---|
| 8 | import { LaunchEditorError } from "./errors/LaunchEditorError";
|
---|
| 9 | import { ReadFileError } from "./errors/ReadFileError";
|
---|
| 10 | import { RemoveFileError } from "./errors/RemoveFileError";
|
---|
| 11 | export interface IEditorParams {
|
---|
| 12 | args: string[];
|
---|
| 13 | bin: string;
|
---|
| 14 | }
|
---|
| 15 | export interface IFileOptions {
|
---|
| 16 | prefix?: string;
|
---|
| 17 | postfix?: string;
|
---|
| 18 | mode?: number;
|
---|
| 19 | template?: string;
|
---|
| 20 | dir?: string;
|
---|
| 21 | }
|
---|
| 22 | export declare type StringCallback = (err: Error, result: string) => void;
|
---|
| 23 | export declare type VoidCallback = () => void;
|
---|
| 24 | export { CreateFileError, LaunchEditorError, ReadFileError, RemoveFileError };
|
---|
| 25 | export declare function edit(text?: string, fileOptions?: IFileOptions): string;
|
---|
| 26 | export declare function editAsync(text: string, callback: StringCallback, fileOptions?: IFileOptions): void;
|
---|
| 27 | export declare class ExternalEditor {
|
---|
| 28 | private static splitStringBySpace;
|
---|
| 29 | text: string;
|
---|
| 30 | tempFile: string;
|
---|
| 31 | editor: IEditorParams;
|
---|
| 32 | lastExitStatus: number;
|
---|
| 33 | private fileOptions;
|
---|
| 34 | readonly temp_file: string;
|
---|
| 35 | readonly last_exit_status: number;
|
---|
| 36 | constructor(text?: string, fileOptions?: IFileOptions);
|
---|
| 37 | run(): string;
|
---|
| 38 | runAsync(callback: StringCallback): void;
|
---|
| 39 | cleanup(): void;
|
---|
| 40 | private determineEditor;
|
---|
| 41 | private createTemporaryFile;
|
---|
| 42 | private readTemporaryFile;
|
---|
| 43 | private removeTemporaryFile;
|
---|
| 44 | private launchEditor;
|
---|
| 45 | private launchEditorAsync;
|
---|
| 46 | }
|
---|