UNPKG

@pnpm/tarball-fetcher

Version:
45 lines 2.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TarballIntegrityError = exports.BadTarballError = void 0; exports.createTarballFetcher = createTarballFetcher; const error_1 = require("@pnpm/error"); const worker_1 = require("@pnpm/worker"); Object.defineProperty(exports, "TarballIntegrityError", { enumerable: true, get: function () { return worker_1.TarballIntegrityError; } }); const remoteTarballFetcher_1 = require("./remoteTarballFetcher"); const localTarballFetcher_1 = require("./localTarballFetcher"); const gitHostedTarballFetcher_1 = require("./gitHostedTarballFetcher"); var errorTypes_1 = require("./errorTypes"); Object.defineProperty(exports, "BadTarballError", { enumerable: true, get: function () { return errorTypes_1.BadTarballError; } }); function createTarballFetcher(fetchFromRegistry, getAuthHeader, opts) { const download = (0, remoteTarballFetcher_1.createDownloader)(fetchFromRegistry, { retry: opts.retry, timeout: opts.timeout, }); const remoteTarballFetcher = fetchFromTarball.bind(null, { download, getAuthHeaderByURI: getAuthHeader, offline: opts.offline, }); return { localTarball: (0, localTarballFetcher_1.createLocalTarballFetcher)(), remoteTarball: remoteTarballFetcher, gitHostedTarball: (0, gitHostedTarballFetcher_1.createGitHostedTarballFetcher)(remoteTarballFetcher, opts), }; } async function fetchFromTarball(ctx, cafs, resolution, opts) { if (ctx.offline) { throw new error_1.PnpmError('NO_OFFLINE_TARBALL', `A package is missing from the store but cannot download it in offline mode. The missing package may be downloaded from ${resolution.tarball}.`); } return ctx.download(resolution.tarball, { getAuthHeaderByURI: ctx.getAuthHeaderByURI, cafs, integrity: resolution.integrity, readManifest: opts.readManifest, onProgress: opts.onProgress, onStart: opts.onStart, registry: resolution.registry, filesIndexFile: opts.filesIndexFile, pkg: opts.pkg, }); } //# sourceMappingURL=index.js.map