prompt-once

1.0.1 • Public • Published

prompt-once

License

Prompts user for a string value once, caches it in a file, returns that value for every subsequent invocation.

Example

Preview

index.js:

const promptOnce = require('prompt-once');

promptOnce('value.txt', 'Type in the value').then(d => {
    console.log('result:', d);
});

API

promptOnce(cacheFile, valueName)
  • cacheFile (string): location of the cache file.
  • valueName (string): name of value that will be displayed in the terminal when prompting the user.
  • Returns a thenable (i.e. has a "then" method) event emitter. It promises the value event. value event notifies the value retrieval, error event notifies any error that occurs during retrieval or when caching the value after its retrieval (.then may resolve successfully but an I/O error could still happen afterwards), cache event notifies successful caching.

History

  • 1.0.1 - 18 June 2019: Fix readme
  • 1.0.0 - 17 June 2019: Initial release

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i prompt-once

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

604 kB

Total Files

5

Last publish

Collaborators

  • jd342