Skip to content

Commit

Permalink
fix(e2e): use pnpmOverrides (#1218)
Browse files Browse the repository at this point in the history
Fixes: dai-shi/waku#1213

---------

Co-authored-by: daishi <[email protected]>
  • Loading branch information
yokos2 and dai-shi committed Feb 8, 2025
1 parent 0fb7337 commit fc4192c
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import net from 'node:net';
import { execSync, exec } from 'node:child_process';
import { createRequire } from 'node:module';
import { fileURLToPath } from 'node:url';
import { cpSync, rmSync, mkdtempSync } from 'node:fs';
import {
cpSync,
rmSync,
mkdtempSync,
readFileSync,
writeFileSync,
} from 'node:fs';
import { join } from 'node:path';
import { tmpdir } from 'node:os';
import type { ChildProcess } from 'node:child_process';
Expand Down Expand Up @@ -179,9 +185,44 @@ export const prepareStandaloneSetup = (fixtureName: string) => {
const wakuPackageTgz = join(standaloneDir, `waku-${version}.tgz`);
const installScript = PACKAGE_INSTALL[packageManager](wakuPackageTgz);
execSync(installScript, { cwd: standaloneDir });
execSync(
`npm install --force ${join(standaloneDir, `waku-${version}.tgz`)}`,
{ cwd: standaloneDir },
const pkg = JSON.parse(
readFileSync(join(standaloneDir, 'package.json'), 'utf-8'),
);
const rootPkg = JSON.parse(
readFileSync(
fileURLToPath(new URL('../package.json', import.meta.url)),
'utf-8',
),
);
const pnpmOverrides = rootPkg.pnpmOverrides;
if (pnpmOverrides !== null && typeof pnpmOverrides === 'object') {
switch (packageManager) {
case 'npm': {
pkg.overrides = {
...pnpmOverrides,
};
break;
}
case 'pnpm': {
pkg.pnpm = {
overrides: {
...pnpmOverrides,
},
};
break;
}
case 'yarn': {
pkg.resolutions = {
...pnpmOverrides,
};
break;
}
}
}
writeFileSync(
join(standaloneDir, 'package.json'),
JSON.stringify(pkg, null, 2),
'utf-8',
);
}
if (mode !== 'DEV' && !built) {
Expand Down

0 comments on commit fc4192c

Please sign in to comment.