diff --git a/package.json b/package.json index 14629874cb3ec..9a34e71a64ce0 100644 --- a/package.json +++ b/package.json @@ -241,7 +241,6 @@ "get-port": "^5.0.0", "getopts": "^2.2.5", "getos": "^3.1.0", - "glob": "^7.1.2", "glob-all": "^3.2.1", "globby": "^11.0.3", "handlebars": "4.7.7", @@ -720,6 +719,7 @@ "find-cypress-specs": "^1.35.1", "form-data": "^4.0.0", "geckodriver": "^4.5.1", + "glob": "^7.1.2", "glob-watcher": "5.0.3", "gulp": "4.0.2", "gulp-babel": "^8.0.0", diff --git a/packages/kbn-spec-to-console/bin/spec_to_console.js b/packages/kbn-spec-to-console/bin/spec_to_console.js index 21922054696f1..f50e8b5015d8f 100644 --- a/packages/kbn-spec-to-console/bin/spec_to_console.js +++ b/packages/kbn-spec-to-console/bin/spec_to_console.js @@ -9,7 +9,7 @@ const fs = require('fs'); const path = require('path'); const program = require('commander'); -const glob = require('glob'); +const globby = require('globby'); const chalk = require('chalk'); const packageJSON = require('../package.json'); @@ -26,7 +26,7 @@ if (!program.glob) { process.exit(1); } -const files = glob.sync(program.glob); +const files = globby.sync(program.glob); const totalFilesCount = files.length; let convertedFilesCount = 0; diff --git a/src/plugins/console/server/services/spec_definitions_service.ts b/src/plugins/console/server/services/spec_definitions_service.ts index e0af9422666af..952e2947a07e8 100644 --- a/src/plugins/console/server/services/spec_definitions_service.ts +++ b/src/plugins/console/server/services/spec_definitions_service.ts @@ -7,9 +7,10 @@ */ import _, { merge } from 'lodash'; -import glob from 'glob'; +import globby from 'globby'; import { basename, join, resolve } from 'path'; import { readFileSync } from 'fs'; +import normalizePath from 'normalize-path'; import { jsSpecLoaders } from '../lib'; @@ -115,8 +116,9 @@ export class SpecDefinitionsService { } private loadJSONSpecInDir(dirname: string) { - const generatedFiles = glob.sync(join(dirname, 'generated', '*.json')); - const overrideFiles = glob.sync(join(dirname, 'overrides', '*.json')); + // we need to normalize paths otherwise they don't work on windows, see https://github.com/elastic/kibana/issues/151032 + const generatedFiles = globby.sync(normalizePath(join(dirname, 'generated', '*.json'))); + const overrideFiles = globby.sync(normalizePath(join(dirname, 'overrides', '*.json'))); return generatedFiles.reduce((acc, file) => { const overrideFile = overrideFiles.find((f) => basename(f) === basename(file)); diff --git a/src/plugins/vis_types/timelion/server/lib/load_functions.js b/src/plugins/vis_types/timelion/server/lib/load_functions.js index 890c5b1df5cdc..70014be1816f4 100644 --- a/src/plugins/vis_types/timelion/server/lib/load_functions.js +++ b/src/plugins/vis_types/timelion/server/lib/load_functions.js @@ -7,8 +7,7 @@ */ import _ from 'lodash'; -import glob from 'glob'; -import path from 'path'; +import globby from 'globby'; import processFunctionDefinition from './process_function_definition'; export default function (directory) { @@ -18,8 +17,8 @@ export default function (directory) { // Get a list of all files and use the filename as the object key const files = _.map( - glob - .sync(path.resolve(__dirname, '../' + directory + '/*.js')) + globby + .sync('../' + directory + '/*.js', { cwd: __dirname }) .filter((filename) => !filename.includes('.test')), function (file) { const name = file.substring(file.lastIndexOf('/') + 1, file.lastIndexOf('.')); @@ -28,7 +27,11 @@ 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(glob.sync(path.resolve(__dirname, '../' + directory + '/*/index.js'))) + const directories = _.chain( + globby.sync('../' + directory + '/*/index.js', { + cwd: __dirname, + }) + ) .map(function (file) { const parts = file.split('/'); const name = parts[parts.length - 2];