prompt-editor

0.1.0 • Public • Published

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.

Package Sidebar

Install

npm i prompt-editor

Weekly Downloads

2

Version

0.1.0

License

MIT

Last publish

Collaborators

  • jonschlinkert