UNPKG

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