In the previous articles, we took a little detour to understand the program variable used in run() function.
async function run(): Promise<void> { console.log("program.resetPreferences:", program.resetPreferences); // a Conf object creation with projectName. // We do not know what Conf does yet and it is okay. const conf = new Conf({ projectName: 'create-next-app' }) // My first thought, where did the program come from? // Let’s find out by looking outside the run() function. // We skipped Conf class but the program variable cannot be skipped. // I know for a fact it is a global variable. if (program.resetPreferences) { conf.clear() console.log(`Preferences reset successfully`) return } if (typeof projectPath === 'string') { projectPath = projectPath.trim() }
Unknown here is Conf. Let’s find out what it is. You have knowns and unknowns and the goal is to make unknowns in your code to knowns as much as possible.
I am thinking conf is used to persist some of your preferences chosen when you run create-next-app because the following is set just before closing the run function:
I initially made this tool to let command-line tools persist some data.
The above quote from the conf package documentation.
Hey, my name is Ramu Narasinga. I study large open-source projects and create content about their codebase architecture and best practices, sharing it through articles, videos.