Debian Codegraph @

scripts/install.js

raw symbols SCIP
1 #!/usr/bin/env node
2
3 const childProcess = require('child_process');
4 const fs = require('fs');
5 const path = require('path');
6
7 const packageRoot = path.resolve(__dirname, '..');
8 const scopedPackageName = `@opencc/opencc-${process.platform}-${process.arch}`;
9 const isSourceCheckout = fs.existsSync(path.join(packageRoot, '.git'));
10
11 if (!isSourceCheckout) {
12 try {
13 const scopedPackage = require(require.resolve(scopedPackageName, {
14 paths: [packageRoot],
15 }));
16 if (scopedPackage && scopedPackage.binaryPath) {
17 process.exit(0);
18 }
19 } catch (error) {
20 if (!error || error.code !== 'MODULE_NOT_FOUND') {
21 throw error;
22 }
23 }
24 }
25
26 const nodeGypBuildBin = require.resolve('node-gyp-build/bin.js');
27 const result = childProcess.spawnSync(process.execPath, [nodeGypBuildBin], {
28 cwd: packageRoot,
29 stdio: 'inherit',
30 });
31
32 process.exit(result.status === null ? 1 : result.status);