Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(v8): fix spawning of subprocesses #726

Merged
merged 4 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion components/git/v8.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'node:path';
import { Readable } from 'node:stream';

import logSymbols from 'log-symbols';

Expand Down Expand Up @@ -83,7 +84,7 @@ export function handler(argv) {
return runAsync('git', args, {
spawnArgs: {
cwd: options.nodeDir,
...input && { input }
...input && { stdio: [Readable.from(input), 'inherit', 'inherit'] }
}
});
};
Expand Down
16 changes: 11 additions & 5 deletions lib/update-v8/minorUpdate.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { spawn } from 'node:child_process';
import path from 'node:path';
import { promises as fs } from 'node:fs';

Expand Down Expand Up @@ -34,8 +35,7 @@ function getLatestV8Version() {
const result = await runAsync('git', ['tag', '-l', `${currentV8Tag}.*`], {
captureStdout: true,
spawnArgs: {
cwd: ctx.v8Dir,
encoding: 'utf8'
cwd: ctx.v8Dir
}
});
const tags = filterAndSortTags(result);
Expand Down Expand Up @@ -66,23 +66,29 @@ function doMinorUpdate() {
}

async function applyPatch(ctx, latestStr) {
const diff = await runAsync(
const diff = spawn(
'git',
['format-patch', '--stdout', `${ctx.currentVersion}...${latestStr}`],
{ captureStdout: true, spawnArgs: { cwd: ctx.v8Dir, encoding: 'utf8' } }
{ cwd: ctx.v8Dir, stdio: ['ignore', 'pipe', 'inherit'] }
);
try {
await runAsync('git', ['apply', '--directory', 'deps/v8'], {
spawnArgs: {
cwd: ctx.nodeDir,
input: diff
stdio: [diff.stdout, 'inherit', 'inherit']
}
});
} catch (e) {
const file = path.join(ctx.nodeDir, `${latestStr}.diff`);
await fs.writeFile(file, diff);
throw new Error(`Could not apply patch.\n${e}\nDiff was stored in ${file}`);
}
if (diff.exitCode !== 0) {
const err = new Error(`git format-patch failed: ${diff.exitCode}`);
err.code = diff.exitCode;
err.messageOnly = true;
throw err;
}
}

function filterAndSortTags(tags) {
Expand Down
Loading