microsoft / ado-npm-auth

This package can automatically use the azureauth CLI to fetch tokens and update a user's .npmrc file for authenticating to Azure DevOps npm feeds.
MIT License
11 stars 9 forks source link

check for project npmrc, add missing/invalid registry error #16

Closed jonchurch closed 7 months ago

jonchurch commented 7 months ago

The Problem

Currently, if your .npmrc is missing the registry key, you'll get an error about not being able to find .npmrc

I didn't realize that the npmrc I am using doesn't specify registry=foo, it was working with just having auth setup without registry itself

The Fix

This PR alters the error messages emitted to be more specific. We will first check if the npmrc exists that we are about to load, and emit an error if it doesn't. Then we will catch the error that is thrown by Config.load when registry is missing/invalid and emit a specific error message.

This way you won't see a "Missing npmrc" error if you just happen to have an invalid or missing registry