UNPKG

workspace-tools

Version:

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

35 lines 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getWorkspacesAsync = exports.getWorkspaces = void 0; const implementations_1 = require("./implementations"); /** * Get an array with names, paths, and package.json contents for each package ("workspace" in * npm/yarn/pnpm terms) within a monorepo. The list of included packages is based on the workspace * manager's config file. */ function getWorkspaces(cwd) { const utils = (0, implementations_1.getWorkspaceUtilities)(cwd); return utils?.getWorkspaces(cwd) || []; } exports.getWorkspaces = getWorkspaces; /** * Get an array with names, paths, and package.json contents for each package ("workspace" in * npm/yarn/pnpm terms) within a monorepo. The list of included packages is based on the workspace * manager's config file. * * NOTE: As of writing, this will start promises to read all package.json files in parallel, * without direct concurrency control. */ async function getWorkspacesAsync(cwd) { const utils = (0, implementations_1.getWorkspaceUtilities)(cwd); if (!utils) { return []; } if (!utils.getWorkspacesAsync) { const managerName = (0, implementations_1.getWorkspaceManagerAndRoot)(cwd)?.manager; throw new Error(`${cwd} is using ${managerName} which has not been converted to async yet`); } return utils.getWorkspacesAsync(cwd); } exports.getWorkspacesAsync = getWorkspacesAsync; //# sourceMappingURL=getWorkspaces.js.map