UNPKG

@tamara027/lerna-terminal

Version:
31 lines (26 loc) 773 B
'use strict'; var fs = require('fs'); var glob = require('glob'); var path = require('path'); var getLerna = require('../getLerna'); /** * @param {Function} onMatch - the callback * @returns {Array<string>} returns an array of pathes to the packages **/ function getLernaPackages(onMatch) { var appDirectory = fs.realpathSync(process.cwd()); var lerna = getLerna(); var packagePaths = []; lerna.packages.forEach(function (packageRelPath) { var files = glob.sync(path.join(appDirectory, packageRelPath, 'package.json')); files.forEach(function (file) { var cleanPath = file.replace(/\/package.json$/, ''); packagePaths.push(cleanPath); if (onMatch) { onMatch(cleanPath); } }); }); return packagePaths; } module.exports = getLernaPackages;