cli: pass npm_token for private repos (#2987)

This commit is contained in:
Ouwen Huang authored and GitHub committed 2022-10-18 22:01:35 -04:00
1 parent 26cc87a2ac
commit 5482de08bc
2 files changed
+18 -2

No files matched your search

+7 -2
View File
@@ -110,8 +110,13 @@ function validate(packageName, version, keyword) {
// Gets the registry of the package. Scoped packages may not be using the global default.
const registryUrlOfPackage = registryUrl(scope);
const response = await fetch(`${registryUrlOfPackage}${packageName}`);
let options = {}
if (process.env.NPM_TOKEN){
options['headers'] = {
'Authorization': `Bearer ${process.env.NPM_TOKEN}`,
}
}
const response = await fetch(`${registryUrlOfPackage}${packageName}`, options);
const json = await response.json();
if (json.error && json.error === NOT_FOUND) {