File tree Expand file tree Collapse file tree
libraries/rush-lib/src/utilities Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ function _trimNpmrcFile(
6363 npmrcFileLines ,
6464 process . env ,
6565 supportEnvVarFallbackSyntax ,
66- filterNpmIncompatibleProperties || false
66+ filterNpmIncompatibleProperties
6767 ) ;
6868
6969 const combinedNpmrc : string = resultLines . join ( '\n' ) ;
@@ -90,6 +90,15 @@ const NPM_INCOMPATIBLE_PROPERTIES: Set<string> = new Set([
9090 'publish-branch'
9191] ) ;
9292
93+ /**
94+ * Regular expression to extract property names from .npmrc lines.
95+ * Matches everything before '=', '[', or whitespace to capture the property name.
96+ * Examples:
97+ * "registry=https://..." -> matches "registry"
98+ * "hoist-pattern[]=..." -> matches "hoist-pattern"
99+ */
100+ const PROPERTY_NAME_REGEX : RegExp = / ^ ( [ ^ = \[ \s ] + ) / ;
101+
93102/**
94103 *
95104 * @param npmrcFileLines The npmrc file's lines
@@ -127,7 +136,7 @@ export function trimNpmrcFileLines(
127136 // Check if this is a property that npm doesn't understand
128137 if ( filterNpmIncompatibleProperties ) {
129138 // Extract the property name (everything before the '=' or '[')
130- const match : RegExpMatchArray | null = line . match ( / ^ ( [ ^ = \[ \s ] + ) / ) ;
139+ const match : RegExpMatchArray | null = line . match ( PROPERTY_NAME_REGEX ) ;
131140 if ( match ) {
132141 const propertyName : string = match [ 1 ] ;
133142
You can’t perform that action at this time.
0 commit comments