-
Notifications
You must be signed in to change notification settings - Fork 122
Expand file tree
/
Copy pathcommon.js
More file actions
36 lines (33 loc) · 845 Bytes
/
common.js
File metadata and controls
36 lines (33 loc) · 845 Bytes
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
import path from 'node:path';
import { promises as fs } from 'node:fs';
import { getNodeV8Version } from './util.js';
export function getCurrentV8Version() {
return {
title: 'Get current V8 version',
task: async(ctx) => {
ctx.currentVersion = await getNodeV8Version(ctx.nodeDir);
}
};
};
export async function checkCwd(ctx) {
let isNode = false;
try {
const nodeVersion = await fs.readFile(
path.join(ctx.nodeDir, 'src/node_version.h')
);
const match = /#define NODE_MAJOR_VERSION (\d+)/.exec(nodeVersion);
if (match) {
isNode = true;
ctx.nodeMajorVersion = parseInt(match[1], 10);
}
} catch (e) {
// ignore
}
if (!isNode) {
throw new Error(
'This does not seem to be the Node.js repository.\n' +
`node-dir: ${ctx.nodeDir}`
);
}
return ctx;
};