Skip to content

src: improve parsing of boolean options #58039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

geeksilva97
Copy link
Contributor

@geeksilva97 geeksilva97 commented Apr 26, 2025

Refs #57960

This PR changes the way booleans are parsed from the config file. Instead of setting --flag=true|false, it adds or not the flag to the options

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/config
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. config Issues or PRs related to the config subsystem needs-ci PRs that need a full CI run. labels Apr 26, 2025
@geeksilva97 geeksilva97 force-pushed the improve-boolean-parsing branch from bf2dcc5 to 01cedaa Compare April 26, 2025 17:59
@geeksilva97
Copy link
Contributor Author

@geeksilva97
Copy link
Contributor Author

This allows passing inspect flag as a boolean. Which I think is the best we can do for now in node_config_file since the env_options_map holds tne --inspect entry as a boolean.

image

Copy link

codecov bot commented Apr 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.26%. Comparing base (68cc1c9) to head (01cedaa).
Report is 20 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #58039      +/-   ##
==========================================
- Coverage   90.26%   90.26%   -0.01%     
==========================================
  Files         630      630              
  Lines      186159   186329     +170     
  Branches    36474    36505      +31     
==========================================
+ Hits       168036   168182     +146     
- Misses      10974    11005      +31     
+ Partials     7149     7142       -7     
Files with missing lines Coverage Δ
src/node_config_file.cc 73.38% <100.00%> (+0.19%) ⬆️

... and 27 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
test('--inspect=true should be parsed correctly', { skip: !process.features.inspector }, async () => {
const result = await spawnPromisified(process.execPath, [
'--no-warnings',
'--expose-internals',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use the internals and not the normal --inspect

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the same test structure. internals is used to get the option value

require("internal/options").getOptionValue("--inspect")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im think you can just do require('node:inspector').url() without exposing internals

@marco-ippolito
Copy link
Member

LGTM with the require('node:inspector').url() suggestion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. config Issues or PRs related to the config subsystem needs-ci PRs that need a full CI run.
3 participants