Skip to content

Commit e4597e9

Browse files
committed
fix(e2e): add project node_modules to NODE_PATH for pushy hdiff
Root cause: loadModule('node-hdiffpatch') in CLI's lib/diff.js uses require.resolve with paths=['.', ...NODE_PATH]. The '.' resolves to cliRoot/lib/, and NODE_PATH only had cliRoot/node_modules/. But node-hdiffpatch was installed in projectRoot/node_modules/, which was not in the search path. The module silently failed to load, the diff command exited without error (or with a swallowed error), and the output file was never created. Fix: add projectRoot/node_modules to NODE_PATH so the CLI can find node-hdiffpatch installed in the project's node_modules.
1 parent 3834477 commit e4597e9

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

Example/e2etest/scripts/prepare-local-update-artifacts.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,18 @@ if (!fs.existsSync(cliEntry)) {
5858
}
5959

6060
function runPushy(args: string[], cwd: string) {
61-
const nodePath = path.join(cliRoot, 'node_modules');
61+
const cliNodeModules = path.join(cliRoot, 'node_modules');
62+
const projectNodeModules = path.join(projectRoot, 'node_modules');
63+
const nodePath = [projectNodeModules, cliNodeModules];
64+
if (process.env.NODE_PATH) {
65+
nodePath.push(process.env.NODE_PATH);
66+
}
6267
const result = spawnSync('node', [cliEntry, ...args], {
6368
cwd,
6469
stdio: 'inherit',
6570
env: {
6671
...process.env,
67-
NODE_PATH: process.env.NODE_PATH
68-
? `${nodePath}${path.delimiter}${process.env.NODE_PATH}`
69-
: nodePath,
72+
NODE_PATH: nodePath.join(path.delimiter),
7073
NO_INTERACTIVE: 'true',
7174
PUSHY_REGISTRY: localRegistry,
7275
RNU_API: localRegistry,

0 commit comments

Comments
 (0)