How to use the semver.gt function in semver

To help you get started, we’ve selected a few semver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ethereum / mist / modules / react / updater.js View on Github external
if (latestCached) {
      console.log('cache latest: ', latestCached.version);
      this.latestCached = latestCached;
      // notify that ui can be started
      this.emit('app-ready', latestCached.filePath, latestCached.version);
    } else {
      latestCached = {
        version: '0.0.0'
      };
    }
    // check remote repo for updates
    let latestBackend = await backend.getLatest();
    console.log('latest backend', latestBackend && latestBackend.version);
    if (
      latestBackend &&
      semver.gt(latestBackend.version, latestCached.version)
    ) {
      // -> update available
      this.emit('update-available', latestBackend);
      return latestBackend;
    }

    return null;
  }
  async checkIntegrity(release) {
github apache / cordova-lib / cordova-lib / src / cordova / plugin.js View on Github external
var upperBound = null;
    var upperBoundRange = null;
    var upperBoundExists = false;

    for(var version in engine) {
        if(semver.valid(semver.clean(version)) && !semver.gt(version, latest)) {
            versions.push(version);
        } else {
            // Check if this is an upperbound; validRange() handles whitespace
            var cleanedRange = semver.validRange(version);
            if(cleanedRange && UPPER_BOUND_REGEX.exec(cleanedRange)) {
                upperBoundExists = true;
                // We only care about the highest upper bound that our project does not support
                if(getFailedRequirements(engine[version], pluginMap, platformMap, cordovaVersion).length !== 0) {
                    var maxMatchingUpperBound = cleanedRange.substring(1);
                    if (maxMatchingUpperBound && (!upperBound || semver.gt(maxMatchingUpperBound, upperBound))) {
                        upperBound = maxMatchingUpperBound;
                        upperBoundRange = version;
                    }
                }
            } else {
                events.emit('verbose', 'Ignoring invalid version in ' + name + ' cordovaDependencies: ' + version + ' (must be a single version <= latest or an upper bound)');
            }
        }
    }

    // If there were no valid requirements, we fall back to old behavior
    if(!upperBoundExists && versions.length === 0) {
        events.emit('verbose', 'Ignoring ' + name + ' cordovaDependencies entry because it did not contain any valid plugin version entries');
        return null;
    }
github storybookjs / storybook / lib / cli / lib / helpers.js View on Github external
let latest;
  try {
    latest = await latestVersion(npmOptions, packageName, constraint);
  } catch (e) {
    if (current) {
      logger.warn(`\n     ${chalk.yellow(e.message)}`);
      return current;
    }

    logger.error(`\n     ${chalk.red(e.message)}`);
    process.exit(1);
  }

  const versionToUse =
    current && (!constraint || satisfies(current, constraint)) && gt(current, latest)
      ? current
      : latest;
  return `^${versionToUse}`;
}
github arrayfire / arrayfire-js / lib / es6 / helpers.js View on Github external
};

helpers.typedArrayToBuffer = function (arr) {
    assert(_.isTypedArray(arr), 'Argument "arr" is not a typed array.');

    return _typedArrayToBuffer(arr);
};

function _typedArrayToBuffer(arr) {
    if (arr.byteLength !== arr.buffer.byteLength) {
        return helpers.arrayToBuffer(arr.buffer, arr.byteOffset, arr.byteLength);
    }
    return helpers.arrayToBuffer(arr.buffer);
}

if (semver.gt(process.versions.node, '5.1.0')) {
    helpers.arrayToBuffer = function (arr, byteOffset, length) {
        return Buffer.from(arr, byteOffset, length);
    };
}
else {
    helpers.arrayToBuffer = function (arr, byteOffset, length) {
        return new Buffer(arr, byteOffset, length);
    };
}
github atom / about / lib / main.js View on Github external
isUpdateAvailable () {
    let availableVersion = window.localStorage.getItem(AvailableUpdateVersion)
    return availableVersion && semver.gt(availableVersion, atom.getVersion())
  },
github electron / fiddle / src / utils / sorted-electron-map.ts View on Github external
.sort((a, b) => {
      if (!semver.valid(a) && !semver.valid(b)) {
        return a.localeCompare(b);
      }

      if (!semver.valid(a)) {
        return -1;
      }

      if (!semver.valid(b)) {
        return 1;
      }

      return semver.gt(a, b, true) ? -1 : 1;
    })
    .map((key) => mapFn(key, versions[key])) as Array;
github ethereum / mist / modules / react / updater.js View on Github external
compareVersions(v1, v2) {
    if (semver.gt(v1.version, v2.version)) {
      return -1;
    }
    if (semver.lt(v1.version, v2.version)) {
      return 1;
    }
    return 0;
  }
}