Retaining the State
Learn how to retain the state of a process when working with CLI applications.
We'll cover the following...
When you are dealing with the process of a script, and it exists, then all the data or the state is forgotten. So, what should you do if you need to retain this state? When you are in a browser, you can use something like local storage or cookies, but you do not have this with a CLI application. Instead of using local storage or cookies, you can create hidden files or dot-files to retain, or persist, your data. In Unix-like systems, files prefixed with a dot are hidden by default, which is why they are called dot-files.
A great example to demonstrate this would be to store some reminders. You will have one script that adds a reminder and one that lists the reminders. You will ensure that you have .reminders.json
present. If not, you will run node setup.js
in the root of the nobot-examples
...