Editor prompt. Opens your text editor and waits for you to save your input during a prompt. Can be used standalone or with a prompt system like [Enquirer].
Switch branches/tags
Nothing to show
Clone or download
Latest commit ba51a35 Oct 13, 2016
Permalink
Failed to load latest commit information.
example adds examples Oct 13, 2016
.editorconfig first commit Aug 28, 2016
.eslintrc.json first commit Aug 28, 2016
.gitattributes first commit Aug 28, 2016
.gitignore first commit Aug 28, 2016
.verb.md generate docs Oct 13, 2016
LICENSE first commit Aug 28, 2016
README.md generate docs Oct 13, 2016
index.js first release Oct 13, 2016
package.json rename, update metadata Oct 13, 2016

README.md

prompt-editor NPM version NPM downloads

Editor prompt. Opens your text editor and waits for you to save your input during a prompt. Can be used standalone or with a prompt system like Enquirer.

Install

Install with npm:

$ npm install --save prompt-editor

Usage

var Editor = require('prompt-editor');
var editor = new Editor({
  type: 'editor',
  name: 'background',
  message: 'Please tell us about yourself in 3 lines or more.',
  validate: function (text) {
    if (text.split('\n').length < 3) {
      return 'Must be at least 3 lines.';
    }
    return true;
  }
});

editor.run()
  .then(function(answers) {
    console.log(answers)
  });

Enquirer usage

var Enquirer = require('enquirer');
var enquirer = new Enquirer();

enquirer.register('editor', require('prompt-editor'));
var questions = [
  {
    type: 'editor',
    name: 'bio',
    message: 'Please write a short bio of at least 3 lines.',
    validate: function (text) {
      if (text.split('\n').length < 3) {
        return 'Must be at least 3 lines.';
      }
      return true;
    }
  }
];

enquirer.ask(questions)
  .then(function(answers) {
    console.log(answers)
  });

Prompts

Related prompt modules:

Attribution

Based on the editor prompt in inquirer.

About

Related projects

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Jon Schlinkert

License

Copyright © 2016, Jon Schlinkert. Released under the MIT license.


This file was generated by verb-generate-readme, v0.1.31, on October 13, 2016.