1.0.1 • Published 5 years ago

prompt-once v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

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