Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on Apr 24, 2024 via pnpm

external-editor 3.1.0

Edit a string with the users preferred text editor using $VISUAL or $ENVIRONMENT
Package summary
Share
0
issues
1
license
6
MIT
Package created
24 Jun 2016
Version published
8 Jul 2019
Maintainers
1
Total deps
6
Direct deps
3
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
6 Packages, Including:
chardet@0.7.0
external-editor@3.1.0
iconv-lite@0.4.24
os-tmpdir@1.0.2
safer-buffer@2.1.2
tmp@0.0.33
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

3
All Dependencies CSV
β“˜ This is a list of external-editor 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
chardet0.7.016.52 kBMIT
prod
iconv-lite0.4.24180.9 kBMIT
prod
tmp0.0.338.42 kBMIT
prod

Visualizations

Frequently Asked Questions

What does external-editor do?

External-editor is a Node.js module that facilitates editing of a string using a user's preferred text editor. It operates by leveraging environment variables $VISUAL or $ENVIRONMENT. This handy tool is designed to streamline text modifications within an integrated development environment.

How do you use external-editor?

To use the external-editor package in your JavaScript projects, you need to first install it using npm by executing npm install external-editor --save in your terminal.

To edit a string, you can utilize the provided .edit convenience method as seen in this snippet:

import {edit} from "external-editor";
const data = edit('\n\n# Please write your text above');
console.log(data);

A more detailed usage example that provides a full feature set including error handling is as follows:

import {ExternalEditor, CreateFileError, ReadFileError, RemoveFileError} from "external-editor"

try {
    const editor = new ExternalEditor();
    const text = editor.run() // the text is also available in editor.text
    
    if (editor.last_exit_status !== 0) {
        console.log("The editor exited with a non-zero code");
    }
} catch (err) {
    if (err instanceOf CreateFileError) {
        console.log('Failed to create the temporary file');
    } else if (err instanceOf ReadFileError) {
        console.log('Failed to read the temporary file');
    } else if (err instanceOf LaunchEditorError) {
        console.log('Failed to launch your editor');
    } else {
        throw err;
    }
}

// Do things with the text

// Eventually call the cleanup to remove the temporary file
try {
    editor.cleanup();   
} catch (err) {
     if (err instanceOf RemoveFileError) {
         console.log('Failed to remove the temporary file');
     } else {
        throw err
    }
}

This bit of code demonstrates the creation of a new instance of the ExternalEditor, running the editor, handling potential errors, working with the resultant text, and cleaning up the temporary file.

Where are the external-editor docs?

The comprehensive documentation for the external-editor package is available within the GitHub repository's README file, reachable at https://github.com/mrkmg/node-external-editor. This source documentation includes comprehensive installation instructions, usage guidelines, API details, error handling guidance, and more, giving developers all the necessary information on how to integrate and use this package effectively.