How to use the @pnpm/lockfile-file.existsWantedLockfile function in @pnpm/lockfile-file

To help you get started, we’ve selected a few @pnpm/lockfile-file 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 / get-context / src / readLockfiles.ts View on Github external
},
): Promise<{
  currentLockfile: Lockfile,
  existsCurrentLockfile: boolean,
  existsWantedLockfile: boolean,
  wantedLockfile: Lockfile,
}> {
  // ignore `pnpm-lock.yaml` on CI servers
  // a latest pnpm should not break all the builds
  const lockfileOpts = {
    ignoreIncompatible: opts.force || isCI,
    wantedVersion: LOCKFILE_VERSION,
  }
  const files = await Promise.all([
    opts.useLockfile && readWantedLockfile(opts.lockfileDir, lockfileOpts)
      || await existsWantedLockfile(opts.lockfileDir) &&
        logger.warn({
          message: `A ${WANTED_LOCKFILE} file exists. The current configuration prohibits to read or write a lockfile`,
          prefix: opts.lockfileDir,
        }),
    readCurrentLockfile(opts.virtualStoreDir, lockfileOpts),
  ])
  const sopts = { lockfileVersion: LOCKFILE_VERSION }
  const importerIds = opts.importers.map((importer) => importer.id)
  const currentLockfile = files[1] || createLockfileObject(importerIds, sopts)
  for (const importerId of importerIds) {
    if (!currentLockfile.importers[importerId]) {
      currentLockfile.importers[importerId] = {
        specifiers: {},
      }
    }
  }