UNPKG

571 BJavaScriptView Raw
1'use strict';
2const _ = require('lodash');
3const globby = require('globby');
4const readPackageJson = require('./read-package-json');
5const path = require('path');
6
7module.exports = function (cwd) {
8 const GLOBBY_PACKAGE_JSON = '{*/package.json,@*/*/package.json}';
9 const installedPackages = globby.sync(GLOBBY_PACKAGE_JSON, {cwd: cwd});
10
11 return _(installedPackages)
12 .map(pkgPath => {
13 const pkg = readPackageJson(path.resolve(cwd, pkgPath));
14 return [pkg.name, pkg.version];
15 })
16 .fromPairs()
17 .valueOf();
18};