-
Notifications
You must be signed in to change notification settings - Fork 696
Expand file tree
/
Copy pathindex.js
More file actions
52 lines (46 loc) · 1.51 KB
/
index.js
File metadata and controls
52 lines (46 loc) · 1.51 KB
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
49
50
51
52
const generateJson = require("./scripts/generateJson");
const generateNativeCode = require("./scripts/generateNativeCode");
const generateMissingTests = require("./scripts/generateMissingTests");
const submoduleStatus = require("../lifecycleScripts/submodules/getStatus");
module.exports = async function generate() {
console.log("[nodegit] Generating native code");
function tryGenerate(numRetries = 3) {
// There appears to be a race condition in the generate code somewhere
// Until we fix that, we should try to generate a few times before
try {
generateJson();
generateNativeCode();
generateMissingTests();
} catch (error) {
if (numRetries > 0) {
console.log(
"[nodegit] WARNING - Failed to generate native code, trying again"
);
tryGenerate(numRetries - 1);
} else {
throw error;
}
}
}
try {
const statuses = await submoduleStatus();
const dirtySubmodules = statuses.filter(
(status) =>
status.onNewCommit || status.needsInitialization || status.workDirDirty
);
if (dirtySubmodules.length) {
console.warn("[nodegit] WARNING - Some submodules are out-of-sync");
dirtySubmodules.forEach(function (submodule) {
console.warn("[nodegit]\t" + submodule.name);
});
}
await tryGenerate();
} catch (e) {
console.error("[nodegit] ERROR - Could not generate native code");
console.error(e);
throw e;
}
};
if (require.main === module) {
module.exports();
}