forked from sqlanywhere/node-sqlanywhere
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.js
45 lines (41 loc) · 1.51 KB
/
build.js
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
// ***************************************************************************
// Copyright (c) 2018 SAP SE or an SAP affiliate company. All rights reserved.
// ***************************************************************************
var db = null;
var exec = require('child_process').exec;
exec( "rm ./build/Release/sqlanywhere.node", function( error, out, err ) {
try {
console.log( "Looking for binaries..." );
// Clean up and try to load modules
db = require( "./lib/index" );
db.createConnection(); // If this step succeeds binaries can be found
console.log( "Binaries found! Install Complete!" );
} catch( err ) {
try {
console.log( "Trying to build binaries" );
var config = require('child_process').exec;
config( "node-gyp configure", function( error, out ) {
if( error ) {
console.log( error, out );
console.log( "Error when executing node-gyp configure" );
process.exit( -1 );
}
var build = require('child_process').exec;
build( "node-gyp build", function( error, out ) {
if( error ) {
console.log( "Error when executing node-gyp configure" );
process.exit( -1 );
}
db = require( "./lib/index" );
conn = db.createConnection();
console.log( "Built Binaries!" );
console.log( "Install Complete!" );
});
});
} catch( err ) {
console.log( "Error Building Binaries. Make sure node-gyp is installed and in the PATH")
throw new Error( "Could not build binaries" );
process.exit( -1 );
}
}
});