Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Commit

Permalink
Added helpers, KIBANA_ROOT environment override (#41)
Browse files Browse the repository at this point in the history
* run is now a named export, added helpers for interacting with the kibana repo

* [config] override the kibana root config with KIBANA_ROOT envvar
  • Loading branch information
spalger authored Apr 28, 2017
1 parent 0c0ee17 commit 54a38cd
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/config_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var readFileSync = require('fs').readFileSync;

var configFiles = [ '.kibana-plugin-helpers.json', '.kibana-plugin-helpers.dev.json' ];
var configCache = {};
var KIBANA_ROOT_OVERRIDE = process.env.KIBANA_ROOT ? resolve(process.env.KIBANA_ROOT) : null;

module.exports = function (root) {
if (!root) root = process.cwd();
Expand All @@ -25,6 +26,7 @@ module.exports = function (root) {

// if the kibanaRoot is set, use resolve to ensure correct resolution
if (config.kibanaRoot) config.kibanaRoot = resolve(root, config.kibanaRoot);
if (KIBANA_ROOT_OVERRIDE) config.kibanaRoot = KIBANA_ROOT_OVERRIDE;

return config;
};
13 changes: 13 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var run = require('./run');
var utils = require('./utils');

module.exports = function () {
console.error(
'running tasks with the default export of @elastic/plugin-helpers is deprecated.' +
'use `require(\'@elastic/plugin-helpers\').run()` instead'
);

return run.apply(this, arguments);
};

Object.assign(module.exports, { run: run }, utils);
28 changes: 28 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var resolve = require('path').resolve;

var pluginConfig = require('./config_file');

function babelRegister() {
var plugin = pluginConfig();
require(resolve(plugin.kibanaRoot, 'src/optimize/babel/register'));
}

function resolveKibanaPath(path) {
var plugin = pluginConfig();
return resolve(plugin.kibanaRoot, path);
}

function createToolingLog(level) {
return require(resolveKibanaPath('src/utils')).createToolingLog(level);
}

function readFtrConfigFile(log, path, settingOverrides) {
return require(resolveKibanaPath('src/functional_test_runner')).readConfigFile(log, path, settingOverrides);
}

module.exports = {
babelRegister: babelRegister,
resolveKibanaPath: resolveKibanaPath,
createToolingLog: createToolingLog,
readFtrConfigFile: readFtrConfigFile,
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@elastic/plugin-helpers",
"version": "6.0.4",
"description": "Just some helpers for kibana plugin devs.",
"main": "lib/run.js",
"main": "lib/index.js",
"bin": {
"plugin-helpers": "bin/plugin-helpers.js"
},
Expand Down

0 comments on commit 54a38cd

Please sign in to comment.