Gitlab@Informatics

Skip to content
Snippets Groups Projects
Select Git revision
  • c6b9a66ab9482e0da3d15914df9c2b88cdfe4256
  • main default protected
2 results

tourController.js

Blame
  • versioning.js 14.17 KiB
    'use strict';
    
    module.exports = exports;
    
    const path = require('path');
    const semver = require('semver');
    const url = require('url');
    const detect_libc = require('detect-libc');
    const napi = require('./napi.js');
    
    let abi_crosswalk;
    
    // This is used for unit testing to provide a fake
    // ABI crosswalk that emulates one that is not updated
    // for the current version
    if (process.env.NODE_PRE_GYP_ABI_CROSSWALK) {
      abi_crosswalk = require(process.env.NODE_PRE_GYP_ABI_CROSSWALK);
    } else {
      abi_crosswalk = require('./abi_crosswalk.json');
    }
    
    const major_versions = {};
    Object.keys(abi_crosswalk).forEach((v) => {
      const major = v.split('.')[0];
      if (!major_versions[major]) {
        major_versions[major] = v;
      }
    });
    
    function get_electron_abi(runtime, target_version) {
      if (!runtime) {
        throw new Error('get_electron_abi requires valid runtime arg');
      }
      if (typeof target_version === 'undefined') {
        // erroneous CLI call
        throw new Error('Empty target version is not supported if electron is the target.');
      }
      // Electron guarantees that patch version update won't break native modules.
      const sem_ver = semver.parse(target_version);
      return runtime + '-v' + sem_ver.major + '.' + sem_ver.minor;
    }
    module.exports.get_electron_abi = get_electron_abi;
    
    function get_node_webkit_abi(runtime, target_version) {
      if (!runtime) {
        throw new Error('get_node_webkit_abi requires valid runtime arg');
      }
      if (typeof target_version === 'undefined') {
        // erroneous CLI call
        throw new Error('Empty target version is not supported if node-webkit is the target.');
      }
      return runtime + '-v' + target_version;
    }
    module.exports.get_node_webkit_abi = get_node_webkit_abi;
    
    function get_node_abi(runtime, versions) {
      if (!runtime) {
        throw new Error('get_node_abi requires valid runtime arg');
      }
      if (!versions) {
        throw new Error('get_node_abi requires valid process.versions object');
      }
      const sem_ver = semver.parse(versions.node);
      if (sem_ver.major === 0 && sem_ver.minor % 2) { // odd series
        // https://github.com/mapbox/node-pre-gyp/issues/124
        return runtime + '-v' + versions.node;
      } else {
        // process.versions.modules added in >= v0.10.4 and v0.11.7
        // https://github.com/joyent/node/commit/ccabd4a6fa8a6eb79d29bc3bbe9fe2b6531c2d8e
        return versions.modules ? runtime + '-v' + (+versions.modules) :