prepare.js 615 B

12345678910111213141516171819
  1. #! /usr/bin/env node
  2. var cp = require('child_process');
  3. var fs = require('fs');
  4. var nodeMajorVersion = +process.version.match(/^v(\d+)\.\d+/)[1];
  5. if (fs.existsSync('src') && nodeMajorVersion >= 10) {
  6. cp.spawnSync('npm', ['run', 'build'], { stdio: 'inherit', shell: true });
  7. } else {
  8. if (!fs.existsSync('lib')) {
  9. console.warn('BSON: No compiled javascript present, the library is not installed correctly.');
  10. if (nodeMajorVersion < 10) {
  11. console.warn(
  12. 'This library can only be compiled in nodejs version 10 or later, currently running: ' +
  13. nodeMajorVersion
  14. );
  15. }
  16. }
  17. }