workspace-tools
Version:
A collection of tools that are useful in a git-controlled monorepo that is managed by one of these tools:
31 lines • 1.25 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPackagePaths = void 0;
const path_1 = __importDefault(require("path"));
const globby_1 = __importDefault(require("globby"));
const packagePathsCache = {};
function getPackagePaths(workspacesRoot, packages, ignorePatterns) {
if (packagePathsCache[workspacesRoot]) {
return packagePathsCache[workspacesRoot];
}
const packagePaths = globby_1.default
.sync(packages.map((glob) => path_1.default.join(glob, "package.json").replace(/\\/g, "/")), {
cwd: workspacesRoot,
absolute: true,
ignore: ["**/node_modules/**", "**/__fixtures__/**"],
stats: false,
})
.map((p) => path_1.default.dirname(p));
if (path_1.default.sep === "/") {
packagePathsCache[workspacesRoot] = packagePaths;
}
else {
packagePathsCache[workspacesRoot] = packagePaths.map((p) => p.replace(/\//g, path_1.default.sep));
}
return packagePathsCache[workspacesRoot];
}
exports.getPackagePaths = getPackagePaths;
//# sourceMappingURL=getPackagePaths.js.map