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 | 'use strict';
|
31 |
|
32 | const fs = require('fs');
|
33 | const nodbUtil = require('../lib/util.js');
|
34 |
|
35 |
|
36 | function log(message) {
|
37 | const args = Array.from(arguments);
|
38 | args.unshift('oracledb');
|
39 | console.log.apply(console, args);
|
40 | }
|
41 |
|
42 |
|
43 | function error(message) {
|
44 | const args = Array.from(arguments);
|
45 | args.unshift('oracledb \x1b[31mERR!\x1b[0m');
|
46 | console.error.apply(console, args);
|
47 | }
|
48 |
|
49 |
|
50 | function done(err) {
|
51 | let installUrl = 'https://oracle.github.io/node-oracledb/INSTALL.html';
|
52 |
|
53 | if (err) {
|
54 | error(err.message);
|
55 | if (err.message.match(/^NJS-067/)) {
|
56 | error('Try compiling node-oracledb source code using ' + installUrl + '#github');
|
57 | } else if (err.message.match(/^NJS-069/)) {
|
58 | error('An older node-oracledb version may work with Node.js ' + process.version);
|
59 | }
|
60 | process.exit(87);
|
61 | } else {
|
62 | let arch;
|
63 |
|
64 | if (process.arch === 'x64') {
|
65 | arch = '64-bit';
|
66 | } else {
|
67 | arch = '32-bit';
|
68 | }
|
69 |
|
70 | if (process.platform === 'linux') {
|
71 | installUrl += '#linuxinstall';
|
72 | } else if (process.platform === 'darwin') {
|
73 | installUrl += '#instosx';
|
74 | } else if (process.platform === 'win32') {
|
75 | installUrl += '#windowsinstallation';
|
76 | }
|
77 |
|
78 | log('********************************************************************************');
|
79 | log('** Node-oracledb ' + nodbUtil.PACKAGE_JSON_VERSION + ' installed in Node.js ' + process.versions.node + ' (' + process.platform + ', ' + process.arch + ')');
|
80 | log('**');
|
81 | log('** To use node-oracledb:');
|
82 | log('** - Oracle Client libraries (' + arch + ') must be available.');
|
83 | log('** - Follow the installation instructions:');
|
84 | log('** ' + installUrl);
|
85 | log('********************************************************************************\n');
|
86 | }
|
87 | }
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 | function checkAvailable(cb) {
|
97 | let vs = process.version.substring(1).split(".").map(Number);
|
98 | if (vs[0] < 8 || (vs[0] === 8 && vs[1] < 16)) {
|
99 | cb(new Error(nodbUtil.getErrorMessage('NJS-069', nodbUtil.PACKAGE_JSON_VERSION, "8.16")));
|
100 | } else if (vs[0] === 10 && vs[1] < 16) {
|
101 | cb(new Error(nodbUtil.getErrorMessage('NJS-069', nodbUtil.PACKAGE_JSON_VERSION, "10.16")));
|
102 | } else {
|
103 | try {
|
104 | fs.statSync(nodbUtil.RELEASE_DIR + '/' + nodbUtil.BINARY_FILE);
|
105 | cb();
|
106 | } catch (err) {
|
107 | cb(new Error(nodbUtil.getErrorMessage('NJS-067', process.platform + ' ' + process.arch)));
|
108 | }
|
109 | }
|
110 | }
|
111 |
|
112 | checkAvailable(done);
|