Skip to content

Commit b7b2a8f

Browse files
targospriyank-p
authored andcommitted
git-node v8: add --v8-dir option
Allows to specify the location of an existing V8 clone. This avoids having to create a separate clone just for this tool. Also fixes the git-node v8 command. `argv` was not read correctly. Fixes: #238
1 parent 040a3d4 commit b7b2a8f

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

components/git/v8.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ module.exports = {
5050
describe: 'Directory where V8 should be cloned',
5151
default: constants.defaultBaseDir
5252
})
53+
.option('v8-dir', {
54+
describe: 'Directory of an existing V8 clone'
55+
})
5356
.option('verbose', {
5457
describe: 'Enable verbose output',
5558
boolean: true,
@@ -63,19 +66,24 @@ function main(argv) {
6366
const options = Object.assign({}, argv);
6467
options.nodeDir = path.resolve(options.nodeDir);
6568
options.baseDir = path.resolve(options.baseDir);
66-
options.v8CloneDir = path.join(options.baseDir, 'v8');
69+
if (!options.v8Dir) {
70+
options.v8Dir = path.join(options.baseDir, 'v8');
71+
} else {
72+
options.v8Dir = path.resolve(options.v8Dir);
73+
}
6774

6875
options.execGitNode = function execGitNode(...args) {
6976
return execa('git', args, { cwd: options.nodeDir });
7077
};
7178
options.execGitV8 = function execGitV8(...args) {
72-
return execa('git', args, { cwd: options.v8CloneDir });
79+
return execa('git', args, { cwd: options.v8Dir });
7380
};
7481

7582
Promise.resolve()
7683
.then(async() => {
7784
await common.checkCwd(options);
78-
const kind = argv._[0];
85+
// First element of argv is 'v8'
86+
const kind = argv._[1];
7987
options[kind] = true;
8088
switch (kind) {
8189
case 'minor':

docs/git-node.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ Defaults to current working directory.
197197
Specify the path where V8 the clone will be maintained.
198198
Defaults to `~/.update-v8`.
199199

200+
##### `--v8-dir=/path/to/v8/`
201+
202+
Specify the path of an existing V8 clone. This will be used instead of cloning
203+
V8 to `baseDir`.
204+
200205
##### `--verbose`
201206

202207
Enable verbose output.

lib/update-v8/majorUpdate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function cloneLocalV8() {
8585
return {
8686
title: 'Clone branch to deps/v8',
8787
task: (ctx) =>
88-
execa('git', ['clone', '-b', ctx.branch, ctx.v8CloneDir, 'deps/v8'], {
88+
execa('git', ['clone', '-b', ctx.branch, ctx.v8Dir, 'deps/v8'], {
8989
cwd: ctx.nodeDir
9090
})
9191
};

lib/update-v8/minorUpdate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function getLatestV8Version() {
2727
task: async(ctx) => {
2828
const currentV8Tag = ctx.currentVersion.slice(0, 3).join('.');
2929
let tags = await execa.stdout('git', ['tag', '-l', `${currentV8Tag}.*`], {
30-
cwd: ctx.v8CloneDir
30+
cwd: ctx.v8Dir
3131
});
3232
tags = toSortedArray(tags);
3333
ctx.latestVersion = tags[0];
@@ -61,7 +61,7 @@ async function doMinorUpdate(ctx, latestStr) {
6161
const diff = await execa.stdout(
6262
'git',
6363
['format-patch', '--stdout', `${currentStr}...${latestStr}`],
64-
{ cwd: ctx.v8CloneDir }
64+
{ cwd: ctx.v8Dir }
6565
);
6666
try {
6767
await execa('git', ['apply', '--directory', 'deps/v8'], {

lib/update-v8/updateV8Clone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function fetchOrigin() {
2020
title: 'Fetch V8',
2121
task: async(ctx, task) => {
2222
try {
23-
await execa('git', ['fetch', 'origin'], { cwd: ctx.v8CloneDir });
23+
await execa('git', ['fetch', 'origin'], { cwd: ctx.v8Dir });
2424
} catch (e) {
2525
if (e.code === 'ENOENT') {
2626
ctx.shouldClone = true;

0 commit comments

Comments
 (0)