kibana/packages/kbn-eslint-import-resolver-kibana/lib/get_plugins.js
Spencer 4f2a19bd9b
[eslint-import-resolver-kibana] bring in repo as package (#17665)
* [eslint-import-resolver-kibana] bring in repo as package

* [eslint-import-resolver] enable prettier
2018-04-11 15:21:29 -07:00

35 lines
1 KiB
JavaScript
Executable file

const { dirname, resolve } = require('path');
const glob = require('glob-all');
module.exports = function getPlugins(config, kibanaPath, projectRoot) {
const resolveToRoot = path => resolve(projectRoot, path);
const pluginDirs = [
...(config.pluginDirs || []).map(resolveToRoot),
resolve(kibanaPath, 'plugins'),
resolve(kibanaPath, 'src/core_plugins'),
];
const pluginPaths = [
...(config.pluginPaths || []).map(resolveToRoot),
// when the rootPackageName is specified we assume that the root of the project
// is not a plugin, so don't include it automatically
...(config.rootPackageName ? [] : [projectRoot]),
];
const globPatterns = [
...pluginDirs.map(dir => resolve(dir, '*/package.json')),
...pluginPaths.map(path => resolve(path, 'package.json')),
];
return glob.sync(globPatterns).map(pkgJsonPath => {
const path = dirname(pkgJsonPath);
const pkg = require(pkgJsonPath);
return {
name: pkg.name,
directory: path,
publicDirectory: resolve(path, 'public'),
};
});
};