support/src/content/prompts.md
If you only need to prompt for one specific thing, then Enquirer probably isn't needed. Instead, you should use one of the individual prompts. Enquirer is useful for when your application needs to expose multiple prompt types, or you need to compose more sophisticated prompts.
You can find prompts created by the Enquirer core team or the community on npm (https://www.npmjs.com/browse/keyword/{{@site.name}}).
Why create a prompt for {{@site.name}}?
Custom prompts are easy to write, and can be used to:
Learn the basics
Before moving on to authoring prompts, it might help to understand how the prompts work:
All prompts inherit from [prompt-base][], which is a constructor function that must be called with a question string or object.
Example
var Prompt = require('prompt-base');
function CustomPrompt() {
Prompt.apply(this, arguments);
}
Prompt.extend(CustomPrompt);
(The Prompt.extend() method is similar to util.inherits(), but it ensures that all properties are inherited and will be invoked in the correct context, including getters and setters)
Usage example
Once published, users will be able to use your prompt like this:
var Prompt = require('prompt-awesome');
var prompt = new Prompt({
name: 'fun',
message: 'Having fun yet?!'
});
prompt.run()
.then(function(answer) {
console.log(answer);
//=> 'of course!'
})
Make your prompt discoverable
If you author a custom prompt, be sure to add {{@site.name}} and {{@site.name}}-prompt to the keywords array in your project's package.json.
Publish
When you're ready to publish your prompt to npm, you can do so with the following command from the root of the project:
$ npm publish
Now that you've published your custom prompt, let's tell the world about the great work you've done!
{{@site.name}} and {{@site.name}}-prompt to package.json.@{{@site.name}}js or use the #{{@site.name}}js hashtag (don't forget the js part on twitter){{@site.name}}js tag in questions)