This repository has been archived by the owner on Nov 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: throw errors for invalid auth configuration (#92)
BREAKING CHANGE: unscoped auth configuration is no longer automatically scoped to a registry. the `validate` method is no longer called automatically. the `_auth` configuration key is no longer split into `username` and `_password`. errors will be thrown by `validate()` if problems are found.
- Loading branch information
Showing
4 changed files
with
192 additions
and
117 deletions.
There are no files selected for viewing
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
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,22 @@ | ||
'use strict' | ||
|
||
class ErrInvalidAuth extends Error { | ||
constructor (problems) { | ||
let message = 'Invalid auth configuration found: ' | ||
message += problems.map((problem) => { | ||
if (problem.action === 'delete') { | ||
return `\`${problem.key}\` is not allowed in ${problem.where} config` | ||
} else if (problem.action === 'rename') { | ||
return `\`${problem.from}\` must be renamed to \`${problem.to}\` in ${problem.where} config` | ||
} | ||
}).join(', ') | ||
message += '\nPlease run `npm config fix` to repair your configuration.`' | ||
super(message) | ||
this.code = 'ERR_INVALID_AUTH' | ||
this.problems = problems | ||
} | ||
} | ||
|
||
module.exports = { | ||
ErrInvalidAuth, | ||
} |
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
Oops, something went wrong.