Get registryURL from server config

This commit is contained in:
Michael Jackson 2018-05-17 15:22:01 -07:00
parent 29697ed201
commit 625e36ec5b
3 changed files with 7 additions and 4 deletions

View File

@ -4,3 +4,6 @@ exports.origin =
process.env.NODE_ENV === "production" || process.env.NODE_ENV === "test"
? "https://unpkg.com"
: `http://localhost:${exports.port}`;
exports.registryURL =
process.env.NPM_REGISTRY_URL || "https://registry.npmjs.org";

View File

@ -5,6 +5,7 @@ const tmpdir = require("os-tmpdir");
const gunzip = require("gunzip-maybe");
const mkdirp = require("mkdirp");
const tar = require("tar-fs");
const createMutex = require("./createMutex");
function createTempPath(name, version) {

View File

@ -1,11 +1,10 @@
require("isomorphic-fetch");
const config = require("../../config");
const createCache = require("./createCache");
const createMutex = require("./createMutex");
const registryURL =
process.env.NPM_REGISTRY_URL || "https://registry.npmjs.org";
const packageInfoCache = createCache("packageInfo");
function fetchPackageInfo(packageName) {
@ -18,7 +17,7 @@ function fetchPackageInfo(packageName) {
encodedPackageName = encodeURIComponent(packageName);
}
const url = `${registryURL}/${encodedPackageName}`;
const url = `${config.registryURL}/${encodedPackageName}`;
return fetch(url, {
headers: {