-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support fallback syntax in .npmrc file
- Loading branch information
Showing
3 changed files
with
104 additions
and
27 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
...on/changes/@microsoft/rush/feature-support_fallback_syntax_in_npmrc_2024-12-04-13-22.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@microsoft/rush", | ||
"comment": "Support fallback syntax in .npmrc file", | ||
"type": "none" | ||
} | ||
], | ||
"packageName": "@microsoft/rush" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
libraries/rush-lib/src/utilities/test/npmrcUtilities.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
// See LICENSE in the project root for license information. | ||
|
||
import { addMissingEnvPrefix, trimNpmrcFileLines } from '../npmrcUtilities'; | ||
|
||
describe('npmrcUtilities', () => { | ||
it(trimNpmrcFileLines.name, () => { | ||
// Normal | ||
expect(trimNpmrcFileLines(['var1=${foo}'], {})).toEqual([addMissingEnvPrefix('var1=${foo}')]); | ||
expect(trimNpmrcFileLines(['var1=${foo}'], { foo: 'test' })).toEqual(['var1=${foo}']); | ||
expect(trimNpmrcFileLines(['var1=${foo-fallback_value}'], {})).toEqual(['var1=${foo-fallback_value}']); | ||
expect(trimNpmrcFileLines(['var1=${foo-fallback_value}'], { foo: 'test' })).toEqual([ | ||
'var1=${foo-fallback_value}' | ||
]); | ||
expect(trimNpmrcFileLines(['var1=${foo:-fallback_value}'], {})).toEqual(['var1=${foo:-fallback_value}']); | ||
expect(trimNpmrcFileLines(['var1=${foo:-fallback_value}'], { foo: 'test' })).toEqual([ | ||
'var1=${foo:-fallback_value}' | ||
]); | ||
|
||
// Multiple environment variables | ||
expect(trimNpmrcFileLines(['var1=${foo}-${bar}'], { foo: 'test' })).toEqual([addMissingEnvPrefix('var1=${foo}-${bar}')]); | ||
expect(trimNpmrcFileLines(['var1=${foo}-${bar}'], { bar: 'test' })).toEqual([addMissingEnvPrefix('var1=${foo}-${bar}')]); | ||
expect(trimNpmrcFileLines(['var1=${foo}-${bar}'], { foo: 'test', bar: 'test' })).toEqual(['var1=${foo}-${bar}']); | ||
expect(trimNpmrcFileLines(['var1=${foo:-fallback_value}-${bar-fallback_value}'], {})).toEqual(['var1=${foo:-fallback_value}-${bar-fallback_value}']); | ||
|
||
// Multiline | ||
expect(trimNpmrcFileLines(['var1=${foo}', 'var2=${bar}'], { foo: 'test' })).toEqual(['var1=${foo}', addMissingEnvPrefix('var2=${bar}')]); | ||
expect(trimNpmrcFileLines(['var1=${foo}', 'var2=${bar}'], { foo: 'test', bar: 'test' })).toEqual(['var1=${foo}', 'var2=${bar}']); | ||
expect(trimNpmrcFileLines(['var1=${foo}', 'var2=${bar-fallback_value}'], { foo: 'test' })).toEqual(['var1=${foo}', 'var2=${bar-fallback_value}']); | ||
expect(trimNpmrcFileLines(['var1=${foo:-fallback_value}', 'var2=${bar-fallback_value}'], {})).toEqual(['var1=${foo:-fallback_value}', 'var2=${bar-fallback_value}']); | ||
|
||
// Malformed | ||
expect(trimNpmrcFileLines(['var1=${foo_fallback_value}'], {})).toEqual([addMissingEnvPrefix('var1=${foo_fallback_value}')]); | ||
expect(trimNpmrcFileLines(['var1=${foo:fallback_value}'], {})).toEqual([addMissingEnvPrefix('var1=${foo:fallback_value}')]); | ||
expect(trimNpmrcFileLines(['var1=${foo:_fallback_value}'], {})).toEqual([addMissingEnvPrefix('var1=${foo:_fallback_value}')]); | ||
expect(trimNpmrcFileLines(['var1=${foo'], {})).toEqual(['var1=${foo']); | ||
}); | ||
}); |