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

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);
  1. Build the create-next-app
npm run build

3. Run the following command

npx create-my-app — reset-preferences

You pass –reset-preferences option to the cli

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

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:

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.

I am open to work on interesting projects. Send me an email at ramu.narasinga@gmail.com

My Github —  https://github.com/ramu-narasinga

My website —  https://ramunarasinga.com

My Youtube channel —  https://www.youtube.com/@ramu-narasinga

Learning platform —  https://thinkthroo.com

Codebase Architecture —  https://app.thinkthroo.com/architecture

Best practices —  https://app.thinkthroo.com/best-practices

Production-grade projects —  https://app.thinkthroo.com/production-grade-projects