UNPKG

pnpm

Version:

A fast implementation of npm install

34 lines 1.05 kB
"use strict"; const getTarballName_1 = require('./getTarballName'); const crypto = require('crypto'); const fetch_1 = require('./fetch'); /** * Resolves a 'remote' package. * * @example * pkg = { * raw: 'http://registry.npmjs.org/is-array/-/is-array-1.0.1.tgz', * scope: null, * name: null, * rawSpec: 'http://registry.npmjs.org/is-array/-/is-array-1.0.1.tgz', * spec: 'http://registry.npmjs.org/is-array/-/is-array-1.0.1.tgz', * type: 'remote' } * resolveTarball(pkg) */ function resolveTarball(spec) { const name = getTarballName_1.default(spec.rawSpec); return Promise.resolve({ id: name + '#' + hash(spec.rawSpec), fetch: fetch_1.createRemoteTarballFetcher({ tarball: spec.rawSpec }) }); } Object.defineProperty(exports, "__esModule", { value: true }); exports.default = resolveTarball; function hash(str) { const hash = crypto.createHash('sha1'); hash.update(str); return hash.digest('hex'); } //# sourceMappingURL=tarball.js.map