How to use @pnpm/package-requester - 2 common examples

To help you get started, we’ve selected a few @pnpm/package-requester 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 / packages / package-store / src / storeController / index.ts View on Github external
networkConcurrency?: number,
    packageImportMethod?: 'auto' | 'hardlink' | 'copy' | 'clone',
    verifyStoreIntegrity: boolean,
  },
): Promise void, saveStateSync: () => void }> {
  const storeDir = initOpts.storeDir
  const unlock = initOpts.locks
    ? await lock(initOpts.storeDir, {
      locks: initOpts.locks,
      stale: initOpts.lockStaleDuration || 60 * 1000, // 1 minute,
      whenLocked: () => globalWarn(`waiting for the store at "${initOpts.storeDir}" to be unlocked...`),
    })
    : null

  const storeIndex = await readStore(initOpts.storeDir) || {}
  const packageRequester = createPackageRequester(resolve, fetchers, {
    networkConcurrency: initOpts.networkConcurrency,
    storeDir: initOpts.storeDir,
    storeIndex,
    verifyStoreIntegrity: initOpts.verifyStoreIntegrity,
  })

  return {
    close: unlock ? async () => { await unlock() } : () => Promise.resolve(undefined),
    closeSync: unlock ? () => unlock.sync() : () => undefined,
    fetchPackage: packageRequester.fetchPackageToStore,
    findPackageUsages,
    getPackageLocation,
    importPackage: createImportPackage(initOpts.packageImportMethod),
    prune,
    requestPackage: packageRequester.requestPackage,
    saveState: saveStore.bind(null, initOpts.storeDir, storeIndex),
github pnpm / pnpm / packages / package-store / src / storeController / index.ts View on Github external
async function getPackageLocation (
    packageId: string,
    packageName: string,
    opts: {
      lockfileDir: string,
      targetEngine?: string,
    }
  ) {
    if (opts.targetEngine) {
      const sideEffectsCacheLocation = (await getCacheByEngine(initOpts.storeDir, packageId))[opts.targetEngine]
      if (sideEffectsCacheLocation) {
        return {
          dir: sideEffectsCacheLocation,
          isBuilt: true,
        }
      }
    }

    return {
      dir: path.join(initOpts.storeDir, pkgIdToFilename(packageId, opts.lockfileDir), 'node_modules', packageName),
      isBuilt: false,
    }
  }

@pnpm/package-requester

Concurrent downloader of npm-compatible packages

MIT
Latest version published 16 days ago

Package Health Score

63 / 100
Full package analysis

Popular @pnpm/package-requester functions