kibana/packages/kbn-eslint-import-resolver-kibana/lib/get_kibana_path.js
Brandon Kobel 4584a8b570
Elastic License 2.0 (#90099)
* Updating everything except the license headers themselves

* Applying ESLint rules

* Manually replacing the stragglers
2021-02-03 18:12:39 -08:00

38 lines
1.3 KiB
JavaScript
Executable file

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
const { resolve } = require('path');
const { debug } = require('./debug');
const DEFAULT_PLUGIN_PATH = '../..';
/*
* Resolves the path to Kibana, either from default setting or config
*/
exports.getKibanaPath = function (config, projectRoot) {
const inConfig = config != null && config.kibanaPath;
// We only allow `.` in the config as we need it for Kibana itself
if (inConfig && config.kibanaPath !== '.') {
throw new Error(
'The `kibanaPath` option has been removed from `eslint-import-resolver-kibana`. ' +
'During development your plugin must live in `./plugins/{pluginName}` ' +
'inside the Kibana folder or `../kibana-extra/{pluginName}` ' +
'relative to the Kibana folder to work with this package.'
);
}
const kibanaPath = inConfig
? resolve(projectRoot, config.kibanaPath)
: resolve(projectRoot, DEFAULT_PLUGIN_PATH);
debug(`Resolved Kibana path: ${kibanaPath}`);
return kibanaPath;
};