Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/setnpmreg.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function createNpmrcFile {
[Parameter(Mandatory = $true)][string]$registry
)
Write-Host "Creating .npmrc file with registry=$registry" -ForegroundColor Blue
New-Item -Path . -Name ".npmrc" -ItemType "file" -Value "registry=$registry" -Force
New-Item -Path . -Name .npmrc -ItemType File -Value "registry=$registry`n" -Force
}

try {
Expand All @@ -19,6 +19,7 @@ try {
if ($response.StatusCode -eq 200) {
Write-Host "adsk npm registry is reachable" -ForegroundColor Green
createNpmrcFile -registry $adskNpmRegistry
Write-Output "//npm.autodesk.com/artifactory/api/npm/:_authToken=\`${NPM_TOKEN}" | Out-File -Append -FilePath .npmrc
Copy link
Preview

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

The authentication token is being written to the .npmrc file without validation that the NPM_TOKEN environment variable exists. This could result in a malformed .npmrc file with 'undefined' or empty token values. Consider adding a check to ensure NPM_TOKEN is set before writing the auth configuration.

Suggested change
Write-Output "//npm.autodesk.com/artifactory/api/npm/:_authToken=\`${NPM_TOKEN}" | Out-File -Append -FilePath .npmrc
if (-not $env:NPM_TOKEN) {
Write-Host "ERROR: NPM_TOKEN environment variable is not set. Cannot write authentication token to .npmrc." -ForegroundColor Red
exit 1
}
Write-Output "//npm.autodesk.com/artifactory/api/npm/:_authToken=${env:NPM_TOKEN}" | Out-File -Append -FilePath .npmrc

Copilot uses AI. Check for mistakes.

}
else {
Write-Host "adsk npm registry is not reachable" -ForegroundColor Red
Expand Down
Loading