DEV Community

Ramu Narasinga
Ramu Narasinga

Posted on • Edited on

Next.js Codebase Analysis <> create-next-app <> index.ts explained — Part 1.4

In the previous article, we logged the program variable and saw some json. In this article, let’s understand how to access an option value passed, specifically program.resetPreferences

Let’s modify the log to print program.resetPreferences

Access options passed in CLI:

  1. Add the following as your first line in run():
console.log("program.resetPreferences:", program.resetPreferences);
Enter fullscreen mode Exit fullscreen mode
  1. Build the create-next-app
npm run build
Enter fullscreen mode Exit fullscreen mode
  1. Run the following command
npx create-my-app --reset-preferences
Enter fullscreen mode Exit fullscreen mode

You pass –reset-preferences option to the cli

options

Conclusion:

So, to find out if any of the options you configured using Commander are passed in the CLI, you can access the flag using camelCase.

Example:

program.useNpm
program.usePnpm
program.resetPreferences
Enter fullscreen mode Exit fullscreen mode

I am building a platform that explains best practices used in open source by elite programmers.

Join the waitlist and I will send you the link to the tutorials once they are ready.

If you have any questions, feel free to reach out to me at ramu.narasinga@gmail.com

Get free courses inspired by the best practices used in open source.

About me:

Website: https://ramunarasinga.com/

Linkedin: https://www.linkedin.com/in/ramu-narasinga-189361128/

Github: https://github.com/Ramu-Narasinga

Email: ramu.narasinga@gmail.com

Learn the best practices used in open source.

Top comments (0)