Skip to content

Commit

Permalink
[globby] normalize paths for windows support (#96476)
Browse files Browse the repository at this point in the history
Co-authored-by: spalger <[email protected]>
  • Loading branch information
Spencer and spalger authored Apr 7, 2021
1 parent 71c326c commit d8ef85e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Path from 'path';

import globby from 'globby';
import normalize from 'normalize-path';

import { parseKibanaPlatformPlugin } from './parse_kibana_platform_plugin';

Expand All @@ -32,7 +33,7 @@ export function simpleKibanaPlatformPluginDiscovery(scanDirs: string[], pluginPa
),
...pluginPaths.map((path) => Path.resolve(path, `kibana.json`)),
])
);
).map((path) => normalize(path));

const manifestPaths = globby.sync(patterns, { absolute: true }).map((path) =>
// absolute paths returned from globby are using normalize or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Path from 'path';
import { REPO_ROOT } from '@kbn/utils';
import { run, createFailError, createFlagError } from '@kbn/dev-utils';
import globby from 'globby';
import normalize from 'normalize-path';

import { getFailures, TestFailure } from './get_failures';
import { GithubApi, GithubIssueMini } from './github_api';
Expand Down Expand Up @@ -61,7 +62,9 @@ export function runFailedTestsReporterCli() {
throw createFlagError('Missing --build-url or process.env.BUILD_URL');
}

const patterns = flags._.length ? flags._ : DEFAULT_PATTERNS;
const patterns = (flags._.length ? flags._ : DEFAULT_PATTERNS).map((p) =>
normalize(Path.resolve(p))
);
log.info('Searching for reports at', patterns);
const reportPaths = await globby(patterns, {
absolute: true,
Expand Down
18 changes: 10 additions & 8 deletions src/dev/build/tasks/package_json/find_used_dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* Side Public License, v 1.
*/

import Path from 'path';
import globby from 'globby';
import normalize from 'normalize-path';
// @ts-ignore
import { parseEntries, dependenciesParseStrategy } from '@kbn/babel-code-parser';

Expand All @@ -21,16 +23,16 @@ export async function findUsedDependencies(listedPkgDependencies: any, baseDir:
// Define the entry points for the server code in order to
// start here later looking for the server side dependencies
const mainCodeEntries = [
`${baseDir}/src/cli/dist.js`,
`${baseDir}/src/cli_keystore/dist.js`,
`${baseDir}/src/cli_plugin/dist.js`,
Path.resolve(baseDir, `src/cli/dist.js`),
Path.resolve(baseDir, `src/cli_keystore/dist.js`),
Path.resolve(baseDir, `src/cli_plugin/dist.js`),
];

const discoveredPluginEntries = await globby([
`${baseDir}/src/plugins/*/server/index.js`,
`!${baseDir}/src/plugins/**/public`,
`${baseDir}/x-pack/plugins/*/server/index.js`,
`!${baseDir}/x-pack/plugins/**/public`,
normalize(Path.resolve(baseDir, `src/plugins/*/server/index.js`)),
`!${normalize(Path.resolve(baseDir, `/src/plugins/**/public`))}`,
normalize(Path.resolve(baseDir, `x-pack/plugins/*/server/index.js`)),
`!${normalize(Path.resolve(baseDir, `/x-pack/plugins/**/public`))}`,
]);

// It will include entries that cannot be discovered
Expand All @@ -40,7 +42,7 @@ export async function findUsedDependencies(listedPkgDependencies: any, baseDir:
// Another way would be to include an index file and import all the functions
// using named imports
const dynamicRequiredEntries = await globby([
`${baseDir}/src/plugins/vis_type_timelion/server/**/*.js`,
normalize(Path.resolve(baseDir, 'src/plugins/vis_type_timelion/server/**/*.js')),
]);

// Compose all the needed entries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Fs from 'fs';
import del from 'del';
import cpy from 'cpy';
import globby from 'globby';
import normalize from 'normalize-path';
import {
ToolingLog,
createAbsolutePathSerializer,
Expand Down Expand Up @@ -98,7 +99,10 @@ it('creates and extracts caches, ingoring dirs with matching merge-base file and

const files = Object.fromEntries(
globby
.sync(outDirs, { dot: true })
.sync(
outDirs.map((p) => normalize(p)),
{ dot: true }
)
.map((path) => [Path.relative(TMP, path), Fs.readFileSync(path, 'utf-8')])
);

Expand Down

0 comments on commit d8ef85e

Please sign in to comment.