hunk.code_window:             } catch (err) {
                 if (installCtx.pkgByPkgId[pkg.id].optional) {
                   // TODO: add parents field to the log
                   skippedOptionalDependencyLogger.debug({
                     details: err,
                     package: {
                       id: pkg.id,
                       name: pkg.name,
                       version: pkg.version,
  
hunk.labels: keep keep keep keep replace keep keep keep keep
hunk.after_edit:                   details: err.toString(),
  
hunk.file_path: src/api/install.ts
hunk.type: replace
file: import {Dependencies} from '@pnpm/types'
  import {WantedDependency} from './types'
  
  export default function (
    deps: Dependencies,
    opts: {
      devDependencies: Dependencies,
      optionalDependencies: Dependencies,
    },
  ): WantedDependency[] {
    if (!deps) return []
    return Object.keys(deps).map((alias) => ({
      alias,
      dev: !!opts.devDependencies[alias],
      optional: !!opts.optionalDependencies[alias],
      pref: deps[alias],
      raw: `${alias}@${deps[alias]}`,
    }))
  }
  
  export function similarDepsToSpecs (
    deps: Dependencies,
    opts: {
      currentPrefs: Dependencies,
      dev: boolean,
      devDependencies: Dependencies,
      optional: boolean,
      optionalDependencies: Dependencies,
    },
  ): WantedDependency[] {
    if (!deps) return []
    return Object.keys(deps).map((alias) => ({
      alias,
      dev: opts.dev || !!opts.devDependencies[alias],
      optional: opts.optional || !!opts.optionalDependencies[alias],
      pref: deps[alias] || opts.currentPrefs[alias],
      raw: `${alias}@${deps[alias]}`,
    }))
  }
  