UNPKG

workspace-tools

Version:

A collection of tools that are useful in a git-controlled monorepo that is managed by one of these tools:

34 lines 1.54 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPnpmWorkspaces = exports.getPnpmWorkspaceRoot = void 0; const path_1 = __importDefault(require("path")); const getPackagePaths_1 = require("../../getPackagePaths"); const getWorkspacePackageInfo_1 = require("../getWorkspacePackageInfo"); const readYaml_1 = require("../../lockfile/readYaml"); const paths_1 = require("../../paths"); function getPnpmWorkspaceRoot(cwd) { const pnpmWorkspacesFile = (0, paths_1.searchUp)("pnpm-workspace.yaml", cwd); if (!pnpmWorkspacesFile) { throw new Error("Could not find pnpm workspaces root"); } return path_1.default.dirname(pnpmWorkspacesFile); } exports.getPnpmWorkspaceRoot = getPnpmWorkspaceRoot; function getPnpmWorkspaces(cwd) { try { const pnpmWorkspacesRoot = getPnpmWorkspaceRoot(cwd); const pnpmWorkspacesFile = path_1.default.join(pnpmWorkspacesRoot, "pnpm-workspace.yaml"); const pnpmWorkspaces = (0, readYaml_1.readYaml)(pnpmWorkspacesFile); const packagePaths = (0, getPackagePaths_1.getPackagePaths)(pnpmWorkspacesRoot, pnpmWorkspaces.packages); const workspaceInfo = (0, getWorkspacePackageInfo_1.getWorkspacePackageInfo)(packagePaths); return workspaceInfo; } catch { return []; } } exports.getPnpmWorkspaces = getPnpmWorkspaces; //# sourceMappingURL=pnpm.js.map