|
| 1 | +import { spawn } from 'node:child_process'; |
1 | 2 | import path from 'node:path'; |
2 | 3 | import { promises as fs } from 'node:fs'; |
3 | 4 |
|
@@ -35,7 +36,7 @@ function getLatestV8Version() { |
35 | 36 | captureStdout: true, |
36 | 37 | spawnArgs: { |
37 | 38 | cwd: ctx.v8Dir, |
38 | | - encoding: 'utf8' |
| 39 | + stdio: ['ignore', 'pipe', 'ignore'] |
39 | 40 | } |
40 | 41 | }); |
41 | 42 | const tags = filterAndSortTags(result); |
@@ -66,23 +67,29 @@ function doMinorUpdate() { |
66 | 67 | } |
67 | 68 |
|
68 | 69 | async function applyPatch(ctx, latestStr) { |
69 | | - const diff = await runAsync( |
| 70 | + const diff = spawn( |
70 | 71 | 'git', |
71 | 72 | ['format-patch', '--stdout', `${ctx.currentVersion}...${latestStr}`], |
72 | | - { captureStdout: true, spawnArgs: { cwd: ctx.v8Dir, encoding: 'utf8' } } |
| 73 | + { cwd: ctx.v8Dir, stdio: ['ignore', 'pipe', 'ignore'] } |
73 | 74 | ); |
74 | 75 | try { |
75 | 76 | await runAsync('git', ['apply', '--directory', 'deps/v8'], { |
76 | 77 | spawnArgs: { |
77 | 78 | cwd: ctx.nodeDir, |
78 | | - input: diff |
| 79 | + stdio: [diff.stdout, 'ignore', 'ignore'] |
79 | 80 | } |
80 | 81 | }); |
81 | 82 | } catch (e) { |
82 | 83 | const file = path.join(ctx.nodeDir, `${latestStr}.diff`); |
83 | 84 | await fs.writeFile(file, diff); |
84 | 85 | throw new Error(`Could not apply patch.\n${e}\nDiff was stored in ${file}`); |
85 | 86 | } |
| 87 | + if (diff.exitCode !== 0) { |
| 88 | + const err = new Error(`git format-patch failed: ${diff.exitCode}`); |
| 89 | + err.code = diff.exitCode; |
| 90 | + err.messageOnly = true; |
| 91 | + throw err; |
| 92 | + } |
86 | 93 | } |
87 | 94 |
|
88 | 95 | function filterAndSortTags(tags) { |
|
0 commit comments