Skip to content

Commit ff79809

Browse files
authored
chore: remove execa dependency (#722)
1 parent 4b2b6fa commit ff79809

File tree

6 files changed

+35
-29
lines changed

6 files changed

+35
-29
lines changed

components/git/v8.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import path from 'node:path';
22

3-
import { execa } from 'execa';
43
import logSymbols from 'log-symbols';
54

65
import { minor, major, backport } from '../../lib/update-v8/index.js';
76
import { defaultBaseDir } from '../../lib/update-v8/constants.js';
87
import { checkCwd } from '../../lib/update-v8/common.js';
8+
import { runAsync } from '../../lib/run.js';
99

1010
export const command = 'v8 [major|minor|backport]';
1111
export const describe = 'Update or patch the V8 engine';
@@ -80,14 +80,16 @@ export function handler(argv) {
8080

8181
options.execGitNode = function execGitNode(cmd, args, input) {
8282
args.unshift(cmd);
83-
return execa('git', args, {
84-
cwd: options.nodeDir,
85-
...input && { input }
83+
return runAsync('git', args, {
84+
spawnArgs: {
85+
cwd: options.nodeDir,
86+
...input && { input }
87+
}
8688
});
8789
};
8890

8991
options.execGitV8 = function execGitV8(...args) {
90-
return execa('git', args, { cwd: options.v8Dir });
92+
return runAsync('git', args, { captureStdout: true, spawnArgs: { cwd: options.v8Dir } });
9193
};
9294

9395
Promise.resolve()

lib/update-v8/backport.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function generatePatches() {
135135
try {
136136
const fullShas = await Promise.all(
137137
shas.map(async(sha) => {
138-
const { stdout } = await ctx.execGitV8('rev-parse', sha);
138+
const stdout = await ctx.execGitV8('rev-parse', sha);
139139
return stdout;
140140
})
141141
);
@@ -146,8 +146,8 @@ function generatePatches() {
146146
]);
147147
return {
148148
sha,
149-
data: patch.stdout,
150-
message: message.stdout
149+
data: patch,
150+
message
151151
};
152152
}));
153153
} catch (e) {

lib/update-v8/majorUpdate.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import path from 'node:path';
22
import { promises as fs } from 'node:fs';
33

44
import Enquirer from 'enquirer';
5-
import { execa } from 'execa';
65
import { Listr } from 'listr2';
76

87
import { getCurrentV8Version } from './common.js';
@@ -16,6 +15,7 @@ import {
1615
} from './util.js';
1716
import applyNodeChanges from './applyNodeChanges.js';
1817
import { chromiumGit, v8Deps } from './constants.js';
18+
import { runAsync } from '../run.js';
1919

2020
export default function majorUpdate() {
2121
return {
@@ -54,7 +54,7 @@ function checkoutBranch() {
5454
'--sort',
5555
'version:refname'
5656
);
57-
const tags = res.stdout.split('\n').filter(isVersionString);
57+
const tags = res.split('\n').filter(isVersionString);
5858
const lastTag = tags[tags.length - 1];
5959
if (lastTag) version = lastTag;
6060
if (version.split('.').length === 3) {
@@ -88,8 +88,8 @@ function cloneLocalV8() {
8888
return {
8989
title: 'Clone branch to deps/v8',
9090
task: (ctx) =>
91-
execa('git', ['clone', '-b', ctx.branch, ctx.v8Dir, 'deps/v8'], {
92-
cwd: ctx.nodeDir
91+
runAsync('git', ['clone', '-b', ctx.branch, ctx.v8Dir, 'deps/v8'], {
92+
spawnArgs: { cwd: ctx.nodeDir }
9393
})
9494
};
9595
}
@@ -106,8 +106,8 @@ function addDepsV8() {
106106
title: 'Track all files in deps/v8',
107107
// Add all V8 files with --force before updating DEPS. We have to do this
108108
// because some files are checked in by V8 despite .gitignore rules.
109-
task: (ctx) => execa('git', ['add', '--force', 'deps/v8'], {
110-
cwd: ctx.nodeDir
109+
task: (ctx) => runAsync('git', ['add', '--force', 'deps/v8'], {
110+
spawnArgs: { cwd: ctx.nodeDir }
111111
})
112112
};
113113
}
@@ -166,6 +166,6 @@ async function fetchFromGit(cwd, repo, commit) {
166166
await removeDirectory(path.join(cwd, '.git'));
167167

168168
function exec(...options) {
169-
return execa('git', options, { cwd });
169+
return runAsync('git', options, { spawnArgs: { cwd } });
170170
}
171171
}

lib/update-v8/minorUpdate.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import path from 'node:path';
22
import { promises as fs } from 'node:fs';
33

44
import Enquirer from 'enquirer';
5-
import { execa } from 'execa';
65
import { Listr } from 'listr2';
76

87
import { getCurrentV8Version } from './common.js';
98
import { isVersionString } from './util.js';
9+
import { runAsync } from '../run.js';
1010

1111
export default function minorUpdate() {
1212
return {
@@ -31,11 +31,14 @@ function getLatestV8Version() {
3131
task: async(ctx) => {
3232
const version = ctx.currentVersion;
3333
const currentV8Tag = `${version.major}.${version.minor}.${version.build}`;
34-
const result = await execa('git', ['tag', '-l', `${currentV8Tag}.*`], {
35-
cwd: ctx.v8Dir,
36-
encoding: 'utf8'
34+
const result = await runAsync('git', ['tag', '-l', `${currentV8Tag}.*`], {
35+
captureStdout: true,
36+
spawnArgs: {
37+
cwd: ctx.v8Dir,
38+
encoding: 'utf8'
39+
}
3740
});
38-
const tags = filterAndSortTags(result.stdout);
41+
const tags = filterAndSortTags(result);
3942
ctx.latestVersion = tags[0];
4043
}
4144
};
@@ -63,15 +66,17 @@ function doMinorUpdate() {
6366
}
6467

6568
async function applyPatch(ctx, latestStr) {
66-
const { stdout: diff } = await execa(
69+
const diff = await runAsync(
6770
'git',
6871
['format-patch', '--stdout', `${ctx.currentVersion}...${latestStr}`],
69-
{ cwd: ctx.v8Dir, encoding: 'utf8' }
72+
{ captureStdout: true, spawnArgs: { cwd: ctx.v8Dir, encoding: 'utf8' } }
7073
);
7174
try {
72-
await execa('git', ['apply', '--directory', 'deps/v8'], {
73-
cwd: ctx.nodeDir,
74-
input: diff
75+
await runAsync('git', ['apply', '--directory', 'deps/v8'], {
76+
spawnArgs: {
77+
cwd: ctx.nodeDir,
78+
input: diff
79+
}
7580
});
7681
} catch (e) {
7782
const file = path.join(ctx.nodeDir, `${latestStr}.diff`);

lib/update-v8/updateV8Clone.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { promises as fs } from 'node:fs';
22

33
import Enquirer from 'enquirer';
4-
import { execa } from 'execa';
54
import { Listr } from 'listr2';
65

76
import { v8Git } from './constants.js';
7+
import { runAsync } from '../run.js';
88

99
export default function updateV8Clone() {
1010
return {
@@ -24,7 +24,7 @@ function fetchOrigin() {
2424
title: 'Fetch V8',
2525
task: async(ctx, task) => {
2626
try {
27-
await execa('git', ['fetch', 'origin'], { cwd: ctx.v8Dir });
27+
await runAsync('git', ['fetch', 'origin'], { spawnArgs: { cwd: ctx.v8Dir } });
2828
} catch (e) {
2929
if (e.code === 'ENOENT') {
3030
ctx.shouldClone = true;
@@ -42,7 +42,7 @@ function createClone() {
4242
title: 'Clone V8',
4343
task: async(ctx) => {
4444
await fs.mkdir(ctx.baseDir, { recursive: true });
45-
await execa('git', ['clone', v8Git], { cwd: ctx.baseDir });
45+
await runAsync('git', ['clone', v8Git], { spawnArgs: { cwd: ctx.baseDir } });
4646
},
4747
enabled: (ctx) => ctx.shouldClone
4848
};

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"clipboardy": "^3.0.0",
4343
"core-validate-commit": "^4.0.0",
4444
"enquirer": "^2.4.1",
45-
"execa": "^8.0.1",
4645
"figures": "^5.0.0",
4746
"ghauth": "^5.0.1",
4847
"inquirer": "^9.2.10",

0 commit comments

Comments
 (0)