Skip to content

lib: expose getOptionValue via process - #46404

Closed
sapphi-red wants to merge 1 commit into
nodejs:mainfrom
sapphi-red:process/get-option-value
Closed

sapphi-red wants to merge 1 commit into
nodejs:mainfrom
sapphi-red:process/get-option-value

Conversation

@sapphi-red

Copy link
Copy Markdown
Contributor

Add process.getOptionValue that exposes getOptionValue in internal/options.

Fixes: #36935

Add `process.getOptionValue` that exposes `getOptionValue`
in `internal/options`.

Fixes: nodejs#36935
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. process Issues and PRs related to the process subsystem. labels Jan 29, 2023
addReadOnlyProcessAlias('_breakFirstLine', '--inspect-brk', false);
addReadOnlyProcessAlias('_breakNodeFirstLine', '--inspect-brk-node', false);

process.getOptionValue = getOptionValue;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
process.getOptionValue = getOptionValue;
process.getOptionValue = function getOptionValue(option) {
require('internal/validators').validateString(option, 'option');
return getOptionValue(option);
};

Comment thread doc/api/process.md
@panva panva added the semver-minor PRs that contain new features and should be released in the next minor version. label Jan 29, 2023
Comment thread doc/api/process.md
added: REPLACEME
-->

> Stability: 1 - Experimental

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Given the experimental nature of many of the individual options, wouldn't this be Experimental forever? Ergo, cannot be relied upon.

@tniessen tniessen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As I said in #36935 (comment), this is risky. semver-minor changes to node options might break applications that use this function.

Comment thread doc/api/process.md
import process from 'node:process';

console.log('--pending-deprecation:', process.getOptionValue('--pending-deprecation'));
console.log('--conditions:', process.getOptionValue('--conditions'));

@jasnell jasnell Jan 29, 2023 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Consider this non-blocking but an alternative approach to implementing this would be to use constants on a process.options object. For instance,

process.options.pendingDeprecation
process.options.conditions

// ... or even

process.options['pending-deprecation']
process.options['conditions']

I think this would help with @panva's concern in relation to experimental status since individual constants can be marked experimental while the process.options is not; as well as just being a bit easier.

@aduh95 aduh95 added the stalled Issues and PRs manually marked as stalled and scheduled for automatic closure. label Sep 20, 2023
@github-actions

Copy link
Copy Markdown
Contributor

This issue/PR was marked as stalled, it will be automatically closed in 30 days. If it should remain open, please leave a comment explaining why it should remain open.

@github-actions

Copy link
Copy Markdown
Contributor

Closing this because it has stalled. Feel free to reopen if this issue/PR is still relevant, or to ping the collaborator who labelled it stalled if you have any questions.

@github-actions github-actions Bot closed this Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. process Issues and PRs related to the process subsystem. semver-minor PRs that contain new features and should be released in the next minor version. stalled Issues and PRs manually marked as stalled and scheduled for automatic closure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Expose getOptionValue via process.getOptionValue

6 participants