{"id":15478385,"url":"https://github.com/enquirer/helper-prompt","last_synced_at":"2026-05-10T09:36:50.699Z","repository":{"id":57262692,"uuid":"92044401","full_name":"enquirer/helper-prompt","owner":"enquirer","description":"Async helper that prompts the user for input then uses the answers to render templates. Must be registered with a library that supports async helpers, like assemble or generate. After that it should work with handlebars, lo-dash or any other node.js engine that supports helper functions.","archived":false,"fork":false,"pushed_at":"2017-05-28T12:23:32.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-19T03:22:12.871Z","etag":null,"topics":["ask","engine","enquirer","generate","handlebars","helper","prompt","question","readline","render","scaffold","scaffolding","terminal"],"latest_commit_sha":null,"homepage":"https://github.com/jonschlinkert","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/enquirer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-22T11:06:06.000Z","updated_at":"2017-08-16T20:19:21.000Z","dependencies_parsed_at":"2022-09-01T06:31:34.537Z","dependency_job_id":null,"html_url":"https://github.com/enquirer/helper-prompt","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enquirer%2Fhelper-prompt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enquirer%2Fhelper-prompt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enquirer%2Fhelper-prompt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enquirer%2Fhelper-prompt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/enquirer","download_url":"https://codeload.github.com/enquirer/helper-prompt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246042013,"owners_count":20714147,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ask","engine","enquirer","generate","handlebars","helper","prompt","question","readline","render","scaffold","scaffolding","terminal"],"created_at":"2024-10-02T04:03:54.131Z","updated_at":"2026-05-10T09:36:45.658Z","avatar_url":"https://github.com/enquirer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# helper-prompt [![NPM version](https://img.shields.io/npm/v/helper-prompt.svg?style=flat)](https://www.npmjs.com/package/helper-prompt) [![NPM monthly downloads](https://img.shields.io/npm/dm/helper-prompt.svg?style=flat)](https://npmjs.org/package/helper-prompt) [![NPM total downloads](https://img.shields.io/npm/dt/helper-prompt.svg?style=flat)](https://npmjs.org/package/helper-prompt)\n\n\u003e Async helper that prompts the user for input then uses the answers to render templates. Must be registered with a library that supports async helpers, like assemble or generate. After that it should work with handlebars, lo-dash or any other node.js engine that supports helper functions.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save helper-prompt\n```\n\n## How it works\n\n1. Prompts you for input\n2. If \"answered\", a second prompt asks if you want to save the answer (this can be skipped)\n3. If \"yes\", the answer is persisted to a [local data store](#data-store), and the prompt will be skipped the next time the same question is asked.\n\nThis is really simple and basic at the moment, it would probably be good to keep it that way. There are lots of interesting things we can do with prompts and templates, but it would be better to do those things with custom implementations.\n\n## Usage\n\nRegister as an async helper with [assemble](https://github.com/assemble/assemble), [generate](https://github.com/generate/generate), [templates](https://github.com/jonschlinkert/templates) or any library that uses [async-helpers](https://github.com/doowb/async-helpers).\n\n```js\nvar prompt = require('helper-prompt');\nvar assemble = require('assemble');\nvar app = assemble();\n\n// \"app\" can be any of the mentioned libraries above\napp.asyncHelper('prompt', prompt());\n```\n\n## Example\n\n```js\nvar templates = require('templates');\nvar app = templates();\n\napp.engine('hbs', require('engine-handlebars'));\napp.asyncHelper('prompt', prompt({save: false}));\n\napp.create('pages');\napp.page('example.hbs', 'My name is: {{prompt \"What is your name?\"}}');\n\napp.render('example.hbs', function(err, view) {\n  if (err) {\n    console.log(err);\n    process.exit(1);\n  }\n  console.log(view.contents.toString());\n  //=\u003e 'My name is: Jon'\n});\n```\n\n## Prompt types\n\nCurrently only the following prompt types are supported:\n\n* [prompt-text](https://github.com/enquirer/prompt-text)\n* [prompt-checkbox](https://github.com/enquirer/prompt-checkbox)\n* [prompt-confirm](https://github.com/enquirer/prompt-confirm)\n\nAny prompt options may be defined using hash arguments.\n\n## Options\n\n### options.save\n\n**Type**: `boolean`\n\n**Default**: `undefined`\n\nBy default, you will be prompted to confirm whether or not an answer value should be persisted. You can disable this by setting `options.save` to false.\n\n```js\nvar prompt = require('helper-prompt');\nvar assemble = require('assemble');\nvar app = assemble();\n\napp.asyncHelper('prompt', prompt({save: false}));\n```\n\n### options.prompt\n\n**Type**: `boolean`\n\n**Default**: `undefined`\n\nDon't skip the prompt, regardless of whether or not the answer was persisted. This is especially useful when `argv` is passed to helper options.\n\nThis is different from `save` in that it forces the prompt to be presented, it does not have any effect on whether or not the answer value is persisted.\n\n```js\nvar prompt = require('helper-prompt');\nvar minimist = require('minimist')(process.argv.slice(2));\nvar assemble = require('assemble');\nvar app = assemble();\n\n// $ your-app --prompt\napp.asyncHelper('prompt', prompt(argv));\n```\n\n## Data store\n\nAnswer values are persisted using [data-store](https://github.com/jonschlinkert/data-store). Options are passed to that library, so you'll need to visit the data-store docs to see all available options and features.\n\nHere is an example of how to change the path of the data store:\n\n```js\n// persist answers to a local folder in \"data/prompt-answers.json\"\nprompt({path: 'data/prompt-answers.json'});\n```\n\n## About\n\n### Related projects\n\n* [enquirer](https://www.npmjs.com/package/enquirer): Intuitive, plugin-based prompt system for node.js. Much faster and lighter alternative to Inquirer, with all… [more](https://github.com/enquirer/enquirer) | [homepage](https://github.com/enquirer/enquirer \"Intuitive, plugin-based prompt system for node.js. Much faster and lighter alternative to Inquirer, with all the same prompt types and more, but without the bloat.\")\n* [prompt-base](https://www.npmjs.com/package/prompt-base): Base prompt module used for creating custom prompts. | [homepage](https://github.com/enquirer/prompt-base \"Base prompt module used for creating custom prompts.\")\n* [prompt-checkbox](https://www.npmjs.com/package/prompt-checkbox): Multiple-choice/checkbox prompt. Can be used standalone or with a prompt system like [Enquirer]. | [homepage](https://github.com/enquirer/prompt-checkbox \"Multiple-choice/checkbox prompt. Can be used standalone or with a prompt system like [Enquirer].\")\n* [prompt-confirm](https://www.npmjs.com/package/prompt-confirm): Confirm (yes/no) prompt. Can be used standalone or with a prompt system like [Enquirer]. | [homepage](https://github.com/enquirer/prompt-confirm \"Confirm (yes/no) prompt. Can be used standalone or with a prompt system like [Enquirer].\")\n\n### Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\nPlease read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.\n\n### Building docs\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n### Running tests\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n### Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on May 28, 2017._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenquirer%2Fhelper-prompt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenquirer%2Fhelper-prompt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenquirer%2Fhelper-prompt/lists"}