JSPM

prompt-editor

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q39875F
  • License MIT

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].

Package Exports

  • prompt-editor

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (prompt-editor) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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

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.