Repository: parcel-bundler/parcel
File: packages/core/package-manager/src/installPackage.js (JavaScript)

Code before:
    projectRoot,
  );

  let configName = configFile && path.basename(configFile);

  // Always use the package manager that seems to be used in the project,
  // falling back to a different one wouldn't update the existing lockfile.
  if (configName === 'package-lock.json') {
    return new Npm();
  } else if (configName === 'pnpm-lock.yaml') {
    return new Pnpm();
  } else if (configName === 'yarn.lock') {
    return new Yarn();
  }

  const currentPackageManager = getCurrentPackageManager();
  if (currentPackageManager) {
    const name = currentPackageManager.name;
    if (name === 'npm') {
      return new Npm();
    } else if (name === 'yarn') {
      return new Yarn();
    } else if (name === 'pnpm') {
      return new Pnpm();
    }
  }

  if (await Yarn.exists()) {
    return new Yarn();
  } else if (await Pnpm.exists()) {
    return new Pnpm();
  } else {
    return new Npm();
  }
}

let queue = new PromiseQueue({maxConcurrent: 1});
let modulesInstalling: Set<string> = new Set();

// Exported so that it may be invoked from the worker api below.
// Do not call this directly! This can result in concurrent package installations
// across multiple instances of the package manager.
export function _addToInstallQueue(
  fs: FileSystem,
  packageManager: PackageManager,
  modules: Array<ModuleRequest>,
  filePath: FilePath,
  projectRoot: FilePath,
  options?: InstallOptions,
): Promise<mixed> {
  modules = modules.map(request => ({

Review comment (suggestion):
```suggestion
  let currentPackageManager = getCurrentPackageManager()?.name;
  if (currentPackageManager === 'npm') {
    return new Npm();
  } else if (currentPackageManager === 'yarn') {
    return new Yarn();
  } else if (currentPackageManager === 'pnpm') {
    return new Pnpm();
  }
```

Code after:
    projectRoot,
  );

  let configName = configFile && path.basename(configFile);

  // Always use the package manager that seems to be used in the project,
  // falling back to a different one wouldn't update the existing lockfile.
  if (configName === 'package-lock.json') {
    return new Npm();
  } else if (configName === 'pnpm-lock.yaml') {
    return new Pnpm();
  } else if (configName === 'yarn.lock') {
    return new Yarn();
  }

  let currentPackageManager = getCurrentPackageManager()?.name;
  if (currentPackageManager === 'npm') {
    return new Npm();
  } else if (currentPackageManager === 'yarn') {
    return new Yarn();
  } else if (currentPackageManager === 'pnpm') {
    return new Pnpm();
  }

  if (await Yarn.exists()) {
    return new Yarn();
  } else if (await Pnpm.exists()) {
    return new Pnpm();
  } else {
    return new Npm();
  }
}

let queue = new PromiseQueue({maxConcurrent: 1});
let modulesInstalling: Set<string> = new Set();

// Exported so that it may be invoked from the worker api below.
// Do not call this directly! This can result in concurrent package installations
// across multiple instances of the package manager.
export function _addToInstallQueue(
  fs: FileSystem,
  packageManager: PackageManager,
  modules: Array<ModuleRequest>,
  filePath: FilePath,
  projectRoot: FilePath,
  options?: InstallOptions,
): Promise<mixed> {
  modules = modules.map(request => ({
    name: validateModuleSpecifier(request.name),
    range: request.range,
  }));