-
Notifications
You must be signed in to change notification settings - Fork 115
/
Copy pathupdateV8Clone.js
48 lines (44 loc) · 1.1 KB
/
updateV8Clone.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { promises as fs } from 'node:fs';
import { v8Git } from './constants.js';
import { forceRunAsync } from '../run.js';
export default function updateV8Clone() {
return {
title: 'Update local V8 clone',
task: (ctx, task) => {
return task.newListr([fetchOrigin(), createClone()]);
}
};
};
function fetchOrigin() {
return {
title: 'Fetch V8',
task: async(ctx, task) => {
try {
await forceRunAsync('git', ['fetch', 'origin'], {
ignoreFailure: false,
spawnArgs: { cwd: ctx.v8Dir, stdio: 'ignore' }
});
} catch (e) {
if (e.code === 'ENOENT') {
ctx.shouldClone = true;
task.skip('V8 clone not present, create it.');
} else {
throw e;
}
}
}
};
}
function createClone() {
return {
title: 'Clone V8',
task: async(ctx) => {
await fs.mkdir(ctx.baseDir, { recursive: true });
await forceRunAsync('git', ['clone', v8Git, ctx.v8Dir], {
ignoreFailure: false,
spawnArgs: { stdio: 'ignore' }
});
},
enabled: (ctx) => ctx.shouldClone
};
}