Skip to content

Commit 511ba83

Browse files
authored
test: Improve workspace dir handling (#8613)
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. I notice this sometimes when working with new packages or similar, and switching branches, you may have leftover empty directories in `packages/`, which leads to integration tests failing unless you make sure to delete the directories.
1 parent df7bb25 commit 511ba83

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

packages/browser-integration-tests/utils/generatePlugin.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { addStaticAsset, addStaticAssetSymlink } from './staticAssets';
88

99
const LOADER_TEMPLATE = fs.readFileSync(path.join(__dirname, '../fixtures/loader.js'), 'utf-8');
1010
const PACKAGES_DIR = '../../packages';
11+
const PACKAGE_JSON = '../../package.json';
1112

1213
/**
1314
* Possible values: See BUNDLE_PATHS.browser
@@ -100,11 +101,8 @@ export const LOADER_CONFIGS: Record<string, { options: Record<string, unknown>;
100101
* so that the compiled versions aren't included
101102
*/
102103
function generateSentryAlias(): Record<string, string> {
103-
const packageNames = fs
104-
.readdirSync(PACKAGES_DIR, { withFileTypes: true })
105-
.filter(dirent => dirent.isDirectory())
106-
.filter(dir => !['apm', 'minimal', 'next-plugin-sentry'].includes(dir.name))
107-
.map(dir => dir.name);
104+
const rootPackageJson = JSON.parse(fs.readFileSync(PACKAGE_JSON, 'utf8')) as { workspaces: string[] };
105+
const packageNames = rootPackageJson.workspaces.map(workspace => workspace.replace('packages/', ''));
108106

109107
return Object.fromEntries(
110108
packageNames.map(packageName => {

0 commit comments

Comments
 (0)