How to use the @pnpm/tarball-fetcher function in @pnpm/tarball-fetcher

To help you get started, we’ve selected a few @pnpm/tarball-fetcher examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pnpm / pnpm / test / download.ts View on Github external
///
import { existsSync } from 'fs'
import fs = require('mz/fs')
import test = require('tape')
import nock = require('nock')
import createFetcher from '@pnpm/tarball-fetcher'
import path = require('path')
import tempy = require('tempy')
import { streamParser, LogBase } from '@pnpm/logger'
import ssri = require('ssri')

const tarballPath = path.join(__dirname, 'tars', 'babel-helper-hoist-variables-6.24.1.tgz')
const tarballSize = 1279
const tarballIntegrity = 'sha1-HssnaJydJVE+rbyZFKc/VAi+enY='
const registry = 'http://example.com/'
const fetch = createFetcher({
  registry,
  rawNpmConfig: {
    registry,
  },
  fetchRetries: 1,
  fetchRetryMintimeout: 0,
  fetchRetryMaxtimeout: 100,
})

test('fail when tarball size does not match content-length', async t => {
  const scope = nock(registry)
    .get('/foo.tgz')
    .times(2)
    .replyWithFile(200, tarballPath, {
      'Content-Length': (1024 * 1024).toString(),
    })
github pnpm / pnpm / test / download.ts View on Github external
registry,
    {
      reqheaders: {
        'authorization': 'Bearer ofjergrg349gj3f2'
      }
    }
  )
  .get('/foo.tgz')
  .replyWithFile(200, tarballPath, {
    'Content-Length': tarballSize.toString(),
  })

  process.chdir(tempy.directory())
  t.comment(`testing in ${process.cwd()}`)

  const fetch = createFetcher({
    alwaysAuth: true,
    registry,
    rawNpmConfig: {
      registry,
      '//example.com/:_authToken': 'ofjergrg349gj3f2',
    },
    fetchRetries: 1,
    fetchRetryMintimeout: 0,
    fetchRetryMaxtimeout: 100,
  })

  const unpackTo = path.resolve('unpacked')
  const cachedTarballLocation = path.resolve('cached')
  const resolution = {
    registry,
    tarball: 'http://example.com/foo.tgz',

@pnpm/tarball-fetcher

Fetcher for packages hosted as tarballs

MIT
Latest version published 20 days ago

Package Health Score

57 / 100
Full package analysis

Popular @pnpm/tarball-fetcher functions