Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
parameters:
RepoNpmrc: '$(Build.SourcesDirectory)/.npmrc'

steps:
- pwsh: |
$repoNpmrc = "${{ parameters.RepoNpmrc }}"
$tempNpmrc = "$(Agent.TempDirectory)/.npmrc"

if (Test-Path $repoNpmrc) {
Copy-Item $repoNpmrc $tempNpmrc -Force
} else {
New-Item -Path $tempNpmrc -ItemType File -Force | Out-Null
Comment on lines +6 to +12
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

The PowerShell step doesn’t set $ErrorActionPreference = 'Stop' (or use -ErrorAction Stop), so a non-terminating error from Copy-Item/New-Item could allow the step to continue and fail later in npmAuthenticate@0 with a less actionable error. Consider forcing terminating behavior and/or explicitly checking the copy/create result before setting NPM_CONFIG_USERCONFIG.

Suggested change
$repoNpmrc = "${{ parameters.RepoNpmrc }}"
$tempNpmrc = "$(Agent.TempDirectory)/.npmrc"
if (Test-Path $repoNpmrc) {
Copy-Item $repoNpmrc $tempNpmrc -Force
} else {
New-Item -Path $tempNpmrc -ItemType File -Force | Out-Null
$ErrorActionPreference = 'Stop'
$repoNpmrc = "${{ parameters.RepoNpmrc }}"
$tempNpmrc = "$(Agent.TempDirectory)/.npmrc"
if (Test-Path $repoNpmrc) {
Copy-Item $repoNpmrc $tempNpmrc -Force -ErrorAction Stop
} else {
New-Item -Path $tempNpmrc -ItemType File -Force -ErrorAction Stop | Out-Null

Copilot uses AI. Check for mistakes.
}

Write-Host "##vso[task.setvariable variable=NPM_CONFIG_USERCONFIG]$tempNpmrc"
displayName: "Prepare temp .npmrc from repo config"

- task: npmAuthenticate@0
displayName: "Authenticate temp .npmrc"
inputs:
workingFile: $(NPM_CONFIG_USERCONFIG)
Loading