install.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var spawn = require('child_process').spawn,
  2. exec = require('child_process').exec;
  3. process.stdout.write("================================================================================\n");
  4. process.stdout.write("= =\n");
  5. process.stdout.write("= To install with C++ bson parser do <npm install mongodb --mongodb:native> =\n");
  6. process.stdout.write("= =\n");
  7. process.stdout.write("================================================================================\n");
  8. // Check if we want to build the native code
  9. var build_native = process.env['npm_package_config_native'] != null ? process.env['npm_package_config_native'] : 'false';
  10. build_native = build_native == 'true' ? true : false;
  11. // If we are building the native bson extension ensure we use gmake if available
  12. if(build_native) {
  13. // Check if we need to use gmake
  14. exec('which gmake', function(err, stdout, stderr) {
  15. // Set up spawn command
  16. var make = null;
  17. // No gmake build using make
  18. if(err != null) {
  19. make = spawn('make', ['total']);
  20. } else {
  21. make = spawn('gmake', ['total']);
  22. }
  23. // Execute spawn
  24. make.stdout.on('data', function(data) {
  25. process.stdout.write(data);
  26. })
  27. make.stderr.on('data', function(data) {
  28. process.stdout.write(data);
  29. })
  30. make.on('exit', function(code) {
  31. process.stdout.write('child process exited with code ' + code + "\n");
  32. })
  33. });
  34. }