UNPKG

workspace-tools

Version:

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

30 lines (29 loc) 1.05 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = __importDefault(require("path")); const globby_1 = __importDefault(require("globby")); function getPackagePaths(workspacesRoot, packages) { const packagePaths = packages.map((glob) => { const globbed = globby_1.default .sync(path_1.default.join(glob, "package.json").replace(/\\/g, "/"), { cwd: workspacesRoot, absolute: true, ignore: ["**/node_modules/**"], }) .map((p) => path_1.default.dirname(p)); return globbed; }); /* * fast-glob returns unix style path, * so we use path.join to align the path with the platform. */ return packagePaths .reduce((acc, cur) => { return [...acc, ...cur]; }) .map((p) => path_1.default.join(p)); } exports.getPackagePaths = getPackagePaths;