prompt-once
v1.0.1
Published
Prompts user for a string value once, caches it in a file, returns that value for every subsequent invocation
Downloads
5
Readme
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 thevalue
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