[8.13] [timelion] Fix load_functions on Windows (#169587) (#180731)

# Backport

This will backport the following commits from `main` to `8.13`:
- [[timelion] Fix load_functions on Windows
(#169587)](https://github.com/elastic/kibana/pull/169587)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Jon","email":"jon@elastic.co"},"sourceCommit":{"committedDate":"2024-04-12T16:43:34Z","message":"[timelion]
Fix load_functions on Windows (#169587)\n\nFixes
https://github.com/elastic/kibana/issues/168605\r\n\r\nTesting -
see\r\nhttps://github.com/elastic/kibana/issues/168605#issuecomment-1769347395\r\n1)
Install Kibana under `C:\\Program Files (x86)`, or a path spaces
and\r\nparentheses. Test builds are available in Buildkite on the
artifacts tab\r\non the `Build Kibana Distribution and Plugins`
step.\r\n2) Create a Timelion visualization\r\n3) `.es(*)` should
load","sha":"d719c89190c37458bc54946af21a36a2a658ccb5","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Visualizations","release_note:skip","ci:build-all-platforms","backport:prev-minor","v8.14.0"],"title":"[timelion]
Fix load_functions on
Windows","number":169587,"url":"https://github.com/elastic/kibana/pull/169587","mergeCommit":{"message":"[timelion]
Fix load_functions on Windows (#169587)\n\nFixes
https://github.com/elastic/kibana/issues/168605\r\n\r\nTesting -
see\r\nhttps://github.com/elastic/kibana/issues/168605#issuecomment-1769347395\r\n1)
Install Kibana under `C:\\Program Files (x86)`, or a path spaces
and\r\nparentheses. Test builds are available in Buildkite on the
artifacts tab\r\non the `Build Kibana Distribution and Plugins`
step.\r\n2) Create a Timelion visualization\r\n3) `.es(*)` should
load","sha":"d719c89190c37458bc54946af21a36a2a658ccb5"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.14.0","branchLabelMappingKey":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/169587","number":169587,"mergeCommit":{"message":"[timelion]
Fix load_functions on Windows (#169587)\n\nFixes
https://github.com/elastic/kibana/issues/168605\r\n\r\nTesting -
see\r\nhttps://github.com/elastic/kibana/issues/168605#issuecomment-1769347395\r\n1)
Install Kibana under `C:\\Program Files (x86)`, or a path spaces
and\r\nparentheses. Test builds are available in Buildkite on the
artifacts tab\r\non the `Build Kibana Distribution and Plugins`
step.\r\n2) Create a Timelion visualization\r\n3) `.es(*)` should
load","sha":"d719c89190c37458bc54946af21a36a2a658ccb5"}}]}] BACKPORT-->

Co-authored-by: Jon <jon@elastic.co>
This commit is contained in:
Kibana Machine 2024-04-12 13:55:08 -04:00 committed by GitHub
parent 1f90eead42
commit 45434581c4
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('/');