UNPKG

@visulima/package

Version:

One Package to rule them all, finds your root-dir, monorepo, or package manager.

52 lines (49 loc) 1.75 kB
import { findPackageManagerSync } from '../package-manager.mjs'; var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); class PackageNotFoundError extends Error { static { __name(this, "PackageNotFoundError"); } /** * @param {string} packageName - The name of the package that was not found. * @param {string} packageManager - The package manager used to install the package. */ constructor(packageName, packageManager) { if (typeof packageName === "string") { packageName = [packageName]; } if (packageName.length === 0) { super("Package was not found."); return; } if (packageManager === void 0) { try { const foundManager = findPackageManagerSync(); packageManager = foundManager.packageManager; } catch { } } if (packageManager === void 0) { packageManager = "npm"; } super(`Package '${packageName.join(" ")}' was not found. Please install it using '${packageManager} install ${packageName.join(" ")}'`); } // eslint-disable-next-line class-methods-use-this get code() { return "PACKAGE_NOT_FOUND"; } // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types set code(_name) { throw new Error("Cannot overwrite code PACKAGE_NOT_FOUND"); } // eslint-disable-next-line class-methods-use-this get name() { return "PackageNotFoundError"; } // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types set name(_name) { throw new Error("Cannot overwrite name of PackageNotFoundError"); } } export { PackageNotFoundError as default };