forked from mongodb/node-mongodb-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.js
41 lines (34 loc) · 1.53 KB
/
install.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
var spawn = require('child_process').spawn,
exec = require('child_process').exec;
process.stdout.write("================================================================================\n");
process.stdout.write("= =\n");
process.stdout.write("= To install with C++ bson parser do <npm install mongodb --mongodb:native> =\n");
process.stdout.write("= =\n");
process.stdout.write("================================================================================\n");
// Check if we want to build the native code
var build_native = process.env['npm_package_config_native'] != null ? process.env['npm_package_config_native'] : 'false';
build_native = build_native == 'true' ? true : false;
// If we are building the native bson extension ensure we use gmake if available
if(build_native) {
// Check if we need to use gmake
exec('which gmake', function(err, stdout, stderr) {
// Set up spawn command
var make = null;
// No gmake build using make
if(err != null) {
make = spawn('make', ['total']);
} else {
make = spawn('gmake', ['total']);
}
// Execute spawn
make.stdout.on('data', function(data) {
process.stdout.write(data);
})
make.stderr.on('data', function(data) {
process.stdout.write(data);
})
make.on('exit', function(code) {
process.stdout.write('child process exited with code ' + code + "\n");
})
});
}