[8.7] [timelion] Fix glob path on windows (#152866) (#153062)

# Backport

This will backport the following commits from `main` to `8.7`:
- [[timelion] Fix glob path on windows
(#152866)](https://github.com/elastic/kibana/pull/152866)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT
[{"author":{"name":"Jon","email":"jon@elastic.co"},"sourceCommit":{"committedDate":"2023-03-09T21:39:05Z","message":"[timelion]
Fix glob path on windows (#152866)\n\nFixes a bug introduced in #138571.
Paths need to be normalized before\r\nbeing passed to our current
version of globby.\r\n\r\nCloses
#150396","sha":"f134d2e44cb936f67f691895a0450529883b71e5","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Visualizations","ci:build-all-platforms","backport:prev-minor","v8.8.0"],"number":152866,"url":"https://github.com/elastic/kibana/pull/152866","mergeCommit":{"message":"[timelion]
Fix glob path on windows (#152866)\n\nFixes a bug introduced in #138571.
Paths need to be normalized before\r\nbeing passed to our current
version of globby.\r\n\r\nCloses
#150396","sha":"f134d2e44cb936f67f691895a0450529883b71e5"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/152866","number":152866,"mergeCommit":{"message":"[timelion]
Fix glob path on windows (#152866)\n\nFixes a bug introduced in #138571.
Paths need to be normalized before\r\nbeing passed to our current
version of globby.\r\n\r\nCloses
#150396","sha":"f134d2e44cb936f67f691895a0450529883b71e5"}}]}]
BACKPORT-->

Co-authored-by: Jon <jon@elastic.co>
This commit is contained in:
Kibana Machine 2023-03-09 17:51:05 -05:00 committed by GitHub
parent 5a854c6357
commit bd52122788
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,6 +9,7 @@
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) {
@ -19,7 +20,7 @@ export default function (directory) {
// Get a list of all files and use the filename as the object key
const files = _.map(
globby
.sync(path.resolve(__dirname, '../' + directory + '/*.js'))
.sync(normalizePath(path.resolve(__dirname, '../' + directory + '/*.js')))
.filter((filename) => !filename.includes('.test')),
function (file) {
const name = file.substring(file.lastIndexOf('/') + 1, file.lastIndexOf('.'));
@ -29,7 +30,7 @@ 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(path.resolve(__dirname, '../' + directory + '/*/index.js'))
globby.sync(normalizePath(path.resolve(__dirname, '../' + directory + '/*/index.js')))
)
.map(function (file) {
const parts = file.split('/');