[timelion] Fix load_functions on Windows (#169587)

Fixes https://github.com/elastic/kibana/issues/168605

Testing - see
https://github.com/elastic/kibana/issues/168605#issuecomment-1769347395
1) Install Kibana under `C:\Program Files (x86)`, or a path spaces and
parentheses. Test builds are available in Buildkite on the artifacts tab
on the `Build Kibana Distribution and Plugins` step.
2) Create a Timelion visualization
3) `.es(*)` should load
This commit is contained in:
Jon 2024-04-12 11:43:34 -05:00 committed by GitHub
parent 891358ff80
commit d719c89190
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,8 +8,6 @@
import _ from 'lodash';
import globby from 'globby';
import path from 'path';
import normalizePath from 'normalize-path';
import processFunctionDefinition from './process_function_definition';
export default function (directory) {
@ -20,7 +18,7 @@ export default function (directory) {
// Get a list of all files and use the filename as the object key
const files = _.map(
globby
.sync(normalizePath(path.resolve(__dirname, '../' + directory + '/*.js')))
.sync('../' + directory + '/*.js', { cwd: __dirname })
.filter((filename) => !filename.includes('.test')),
function (file) {
const name = file.substring(file.lastIndexOf('/') + 1, file.lastIndexOf('.'));
@ -30,7 +28,9 @@ export default function (directory) {
// Get a list of all directories with an index.js, use the directory name as the key in the object
const directories = _.chain(
globby.sync(normalizePath(path.resolve(__dirname, '../' + directory + '/*/index.js')))
globby.sync('../' + directory + '/*/index.js', {
cwd: __dirname,
})
)
.map(function (file) {
const parts = file.split('/');