From 8eeb173b58106da5a069cdc22e7af733976d5484 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 24 Jul 2023 11:22:47 +0200 Subject: [PATCH] test: Improve workspace dir handling Instead of looking up folders in `package`, fetch the packages from the root package.json. This way, if you e.g. have empty folders or similar in your `package/` dir, it will not fail. --- .../browser-integration-tests/utils/generatePlugin.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/browser-integration-tests/utils/generatePlugin.ts b/packages/browser-integration-tests/utils/generatePlugin.ts index c25cf823c4a5..45fe1cfb9a94 100644 --- a/packages/browser-integration-tests/utils/generatePlugin.ts +++ b/packages/browser-integration-tests/utils/generatePlugin.ts @@ -8,6 +8,7 @@ import { addStaticAsset, addStaticAssetSymlink } from './staticAssets'; const LOADER_TEMPLATE = fs.readFileSync(path.join(__dirname, '../fixtures/loader.js'), 'utf-8'); const PACKAGES_DIR = '../../packages'; +const PACKAGE_JSON = '../../package.json'; /** * Possible values: See BUNDLE_PATHS.browser @@ -100,11 +101,8 @@ export const LOADER_CONFIGS: Record; * so that the compiled versions aren't included */ function generateSentryAlias(): Record { - const packageNames = fs - .readdirSync(PACKAGES_DIR, { withFileTypes: true }) - .filter(dirent => dirent.isDirectory()) - .filter(dir => !['apm', 'minimal', 'next-plugin-sentry'].includes(dir.name)) - .map(dir => dir.name); + const rootPackageJson = JSON.parse(fs.readFileSync(PACKAGE_JSON, 'utf8')) as { workspaces: string[] }; + const packageNames = rootPackageJson.workspaces.map(workspace => workspace.replace('packages/', '')); return Object.fromEntries( packageNames.map(packageName => {