exports.loadRequiredModules = function()

in jones-ndb/impl/ndb/ndb_service_provider.js [53:100]


exports.loadRequiredModules = function() {
  var err, ldp, msg, jsonconfig, libpath;
  var existsSync = fs.existsSync || path.existsSync;

  /* Load the binary */
  try {
    require(conf.binary);
  } catch(e) {
    ldp = process.platform === 'darwin' ? 'DYLD_LIBRARY_PATH' : 'LD_LIBRARY_PATH';
    msg = "\n\n" +
      "  The ndb adapter cannot load the compiled module ndb_adapter.node.\n";
    if(existsSync(conf.binary)) {
      msg +=
      "  This module has been built, but was not succesfully loaded.  Perhaps \n" +
      "  setting " + ldp + " to the mysql lib directory (containing \n" +
      "  libndbclient) will resolve the problem.\n\n";
      if(existsSync(gypConfigFile)) {
        try {
          jsonconfig = fs.readFileSync(gypConfigFile, 'utf8');
          jsonconfig = JSON.parse(jsonconfig);
          libpath = path.join(jsonconfig.variables.mysql_path, "lib");
          msg += "  e.g.:\n";
          msg += "  export " + ldp + "=" + libpath + "\n\n";
        }
        catch(ignore) {}
      }
    }
    else {
      msg +=
      "  For help building jones-ndb, run \"node configure\" \n\n";
    }
    msg += "Original error: \n--------------- \n" + e.message;
    err = new Error(msg);
    err.cause = e;
    throw err;
  }

  /* Load jones-mysql */
  try {
    require("jones-mysql");
  } catch(e2) {
    msg = "jones-ndb requires mysql for metadata operations.\n";
    msg += "Original error: " + e2.message;
    err = new Error(msg);
    err.cause = e2;
    throw err;
  }
};