blob: 9d62b542196b1d7f34ba52897f65d87df8476ac5 (
plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
|
import { execSync } from 'child_process';
function testRe2() {
execSync(
`node -e "try{require('re2')('.*').exec('test')}catch(e){console.error(e);if(e.code === 'ERR_DLOPEN_FAILED' && e.message.includes('NODE_MODULE_VERSION')) process.exit(1); else process.exit(-1)}"`,
{ stdio: 'inherit' },
);
console.log(`Ok.`);
}
function testSqlite() {
execSync(
`node -e "try{new require('better-sqlite3')(':memory:')}catch(e){console.error(e);if(e.code === 'ERR_DLOPEN_FAILED' && e.message.includes('NODE_MODULE_VERSION')) process.exit(1); else process.exit(-1)}"`,
{ stdio: 'inherit' },
);
console.log(`Ok.`);
}
(() => {
console.log('Checking re2 ... ');
try {
testRe2();
} catch (e) {
console.error(`Failed.\n${e}`);
try {
if (e.status === 1) {
console.log(`Retry re2 install ...`);
execSync('pnpm run install', {
stdio: 'inherit',
cwd: `${process.cwd()}/node_modules/re2`,
});
testRe2();
return;
}
} catch (e1) {
console.error(`Retry failed.\n${e1}`);
}
process.exit(1);
}
})();
(() => {
console.log('Checking better-sqlite3 ... ');
try {
testSqlite();
} catch (e) {
console.error(`Failed.\n${e}`);
try {
if (e.status === 1) {
console.log(`Retry better-sqlite3 install ...`);
execSync('pnpm run install', {
stdio: 'inherit',
cwd: `${process.cwd()}/node_modules/better-sqlite3`,
});
testSqlite();
return;
}
} catch (e1) {
console.error(`Retry failed.\n${e1}`);
}
process.exit(1);
}
})();
|