1.0.1 • Published 7 years ago
prompt-once v1.0.1
prompt-once
Prompts user for a string value once, caches it in a file, returns that value for every subsequent invocation.
Example

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 thevalueevent.valueevent notifies the value retrieval,errorevent 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),cacheevent notifies successful caching.
History
- 1.0.1 - 18 June 2019: Fix readme
- 1.0.0 - 17 June 2019: Initial release