1 | 'use strict';
|
2 | const _ = require('lodash');
|
3 | const globby = require('globby');
|
4 | const readPackageJson = require('./read-package-json');
|
5 | const path = require('path');
|
6 |
|
7 | module.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 | };
|