Created
July 12, 2017 06:44
-
-
Save danielo515/6cff10095dfdbd2811a98b4d20eb2189 to your computer and use it in GitHub Desktop.
List all packages under a lerna repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const Fs = require('fs'); | |
const ReadDir = Fs.readdirSync; | |
const Stat = Fs.statSync; | |
module.exports = (basePath) => { | |
const getAllPackages = () => ReadDir(basePath) | |
.map((d) => `${basePath}/${d}`) | |
.filter((d) => Stat(d).isDirectory()) | |
.map((d) => ReadDir(d).filter((i) => (/package\.json/i).test(i)).map((x) => `${d}/${x}`)) | |
.reduce( (all,p) => p.concat(all),[]); | |
return getAllPackages().map( (p) => ({ [require(p).name] : require(p).version })); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment