rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[rush-lib] Forward parameterNamesToIgnore to child processes via environment variable

Open Copilot opened this issue 1 month ago • 2 comments

Summary

Adds RUSHSTACK_CLI_IGNORED_PARAMETER_NAMES environment variable to forward the parameterNamesToIgnore operation setting from rush-project.json to child processes during phased command execution. The environment variable name is exported as a public constant for use by consumers.

Details

Implementation:

  • Created IgnoredParametersPlugin that taps the createEnvironmentForOperation hook
  • Reads parameterNamesToIgnore directly from operation.settings (raw configuration value, not CLI-affected values)
  • Sets RUSHSTACK_CLI_IGNORED_PARAMETER_NAMES with comma-separated parameter names when defined
  • Exported the environment variable name as RUSHSTACK_CLI_IGNORED_PARAMETER_NAMES_ENV_VAR constant for external use
  • Integrated into PhasedScriptAction alongside other standard plugins

Design:

  • Follows pattern established by NodeDiagnosticDirPlugin
  • Naming consistent with existing RUSHSTACK_FILE_ERROR_BASE_FOLDER convention
  • Only sets environment variable when configuration explicitly defines ignored parameters
  • Environment variable name exported as public constant to avoid hardcoded strings in consuming code
  • Uses comma separator to clearly indicate enumeration of parameter names (not command line arguments)

Example:

Given a rush-project.json with:

{
  "operationSettings": [
    {
      "operationName": "build",
      "parameterNamesToIgnore": ["--verbose", "--production"]
    }
  ]
}

Child processes will receive:

RUSHSTACK_CLI_IGNORED_PARAMETER_NAMES="--verbose,--production"

Consumers can reference the environment variable name using:

import { RUSHSTACK_CLI_IGNORED_PARAMETER_NAMES_ENV_VAR } from '@microsoft/rush-lib';

How it was tested

Added unit tests verifying:

  • Environment variable set correctly when parameterNamesToIgnore is specified
  • Environment variable not set when parameterNamesToIgnore is absent
  • Correct values forwarded for different project configurations
  • Tests use the exported constant to avoid hardcoded strings

All tests pass. No regressions in existing test suite.

Impacted documentation

None. This is an internal implementation detail for plugin authors.

Original prompt

In rush-lib, use the createEnvironmentForOperation phased command hook to forward the value of the parameterNamesToIgnore operation setting to child processes as an environment variable. Use similar naming to the RUSHSTACK_BASE_ERROR_FOLDER environment variable.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Dec 09 '25 22:12 Copilot

@copilot Run rush change --no-fetch --bulk --bump-type none --message "${description}" to create a change file, then ensure that the file path and content of the created change file reference @microsoft/rush and not any other package.

dmichon-msft avatar Dec 10 '25 21:12 dmichon-msft

@copilot Run rush change --no-fetch --bulk --bump-type none --message "${description}" to create a change file, then ensure that the file path and content of the created change file reference `@micr...

Created change file at common/changes/@microsoft/rush/copilot-forward-parameter-names-ignore_2025-12-10-21-30.json with bump-type "none" and the specified message. The file correctly references @microsoft/rush package. See commit 3614780.

Copilot avatar Dec 10 '25 21:12 Copilot