Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/kbn-utils/src/path/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
*/

import { join } from 'path';
import { accessSync, constants } from 'fs';
import { accessSync, constants, readFileSync } from 'fs';
import { TypeOf, schema } from '@kbn/config-schema';
import { REPO_ROOT } from '@kbn/repo-info';
import { getConfigFromFiles } from '@kbn/config';

const isString = (v: any): v is string => typeof v === 'string';

Expand Down Expand Up @@ -57,7 +58,15 @@ export const getConfigDirectory = () => findFile(CONFIG_DIRECTORIES);
* Get the directory containing runtime data
* @internal
*/
export const getDataPath = () => findFile(DATA_PATHS);
export const getDataPath = () => {
// Use the KIBANA_DATA_PATH environment variable if it is set
if (process.env.KIBANA_DATA_PATH) {
return process.env.KIBANA_DATA_PATH;
}

// Fallback to predefined data paths if the environment variable is not set
return findFile(DATA_PATHS);
};

/**
* Get the directory containing logs
Expand Down