Skip to content

Commit a8a9f05

Browse files
committed
ensure we use absolute paths and fix overrides
1 parent 26432cb commit a8a9f05

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

dev-packages/e2e-tests/lib/copyToTemp.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable no-console */
22
import { readFileSync, writeFileSync } from 'fs';
33
import { cp } from 'fs/promises';
4-
import { isAbsolute, join } from 'path';
4+
import { isAbsolute, join, resolve } from 'path';
55

66
export async function copyToTemp(originalPath: string, tmpDirPath: string): Promise<void> {
77
// copy files to tmp dir
@@ -35,7 +35,7 @@ function fixPackageJson(cwd: string): void {
3535
const extendsPath = packageJson.volta.extends;
3636
// We add a virtual dir to ensure that the relative depth is consistent
3737
// dirPath is relative to ./../test-applications/xxx
38-
const newPath = join(__dirname, 'virtual-dir/', extendsPath);
38+
const newPath = resolve(__dirname, 'virtual-dir/', extendsPath);
3939
packageJson.volta.extends = newPath;
4040
console.log(`Fixed volta.extends to ${newPath}`);
4141
} else {
@@ -45,7 +45,8 @@ function fixPackageJson(cwd: string): void {
4545
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
4646
}
4747

48-
function fixFileLinkDependencies(dependencyObj: Record<string, string>): void {
48+
// Exported for pnpmOverrides as well
49+
export function fixFileLinkDependencies(dependencyObj: Record<string, string>): void {
4950
for (const [key, value] of Object.entries(dependencyObj)) {
5051
const prefix = value.startsWith('link:') ? 'link:' : value.startsWith('file:') ? 'file:' : null;
5152
if (!prefix) {
@@ -59,9 +60,9 @@ function fixFileLinkDependencies(dependencyObj: Record<string, string>): void {
5960

6061
// We add a virtual dir to ensure that the relative depth is consistent
6162
// dirPath is relative to ./../test-applications/xxx
62-
const newPath = join(__dirname, 'virtual-dir/', dirPath);
63+
const absPath = resolve(__dirname, 'virtual-dir', dirPath);
6364

64-
dependencyObj[key] = `${prefix}${newPath}`;
65-
console.log(`Fixed ${key} dependency to ${newPath}`);
65+
dependencyObj[key] = `${prefix}${absPath}`;
66+
console.log(`Fixed ${key} dependency to ${absPath}`);
6667
}
6768
}

dev-packages/e2e-tests/lib/pnpmOverrides.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { readFile, writeFile } from 'fs/promises';
22
import * as path from 'path';
33
import { getPublishedSentryTarballPackageNames, packedSymlinkFilename } from './packedTarballUtils';
4+
import { fixFileLinkDependencies } from './copyToTemp';
45

56
/**
67
* For a given temp test application directory, add pnpm.overrides to pin the internal Sentry packages to the packed tarballs.
@@ -24,11 +25,14 @@ export async function addPnpmOverrides(tmpDirPath: string, packedDirPath: string
2425
overrides[packageName] = `file:${packedDirPath}/${packedSymlinkFilename(packageName)}`;
2526
}
2627

28+
const fixedOverrides = packageJson.pnpm?.overrides ?? {};
29+
fixFileLinkDependencies(fixedOverrides);
30+
2731
packageJson.pnpm = {
2832
...packageJson.pnpm,
2933
overrides: {
3034
...overrides,
31-
...packageJson.pnpm?.overrides,
35+
...fixedOverrides,
3236
},
3337
};
3438

0 commit comments

Comments
 (0)