How to use the semver.lt 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 expo / expo-cli / packages / xdl / src / Simulator.ts View on Github external
console.error('No version number found from `xcodebuild -version`.');
      Logger.global.error(
        'Unable to check Xcode version. Command ran successfully but no version number was found.'
      );
      return false;
    }

    // we're cheating to use the semver lib, but it expects a proper patch version which xcode doesn't have
    const version = matches[0] + '.0';

    if (!semver.valid(version)) {
      console.error('Invalid version number found: ' + matches[0]);
      return false;
    }

    if (semver.lt(version, SUGGESTED_XCODE_VERSION)) {
      console.warn(
        `Found Xcode ${version}, which is older than the recommended Xcode ${SUGGESTED_XCODE_VERSION}.`
      );
    }
  } catch (e) {
    // how would this happen? presumably if Simulator id is found then xcodebuild is installed
    console.error(`Unable to check Xcode version: ${e}`);
    Logger.global.error(XCODE_NOT_INSTALLED_ERROR);
    return false;
  }

  // make sure we can run simctl
  try {
    await _xcrunAsync(['simctl', 'help']);
  } catch (e) {
    if (e.isXDLError) {
github microsoft / app-store-vsts-extension / make.js View on Github external
var getExternals = util.getExternals;
var createResjson = util.createResjson;
var createTaskLocJson = util.createTaskLocJson;
var validateTask = util.validateTask;

// global paths
var buildPath = path.join(__dirname, '_build', 'Tasks');
var buildTestsPath = path.join(__dirname, '_build', 'Tests');
var commonPath = path.join(__dirname, '_build', 'Tasks', 'Common');
var packagePath = path.join(__dirname, '_package');
var testTasksPath = path.join(__dirname, '_test', 'Tasks');
var testPath = path.join(__dirname, '_test', 'Tests');

// node min version
var minNodeVer = '4.0.0';
if (semver.lt(process.versions.node, minNodeVer)) {
    fail('requires node >= ' + minNodeVer + '.  installed: ' + process.versions.node);
}

// add node modules .bin to the path so we can dictate version of tsc etc...
var binPath = path.join(__dirname, 'node_modules', '.bin');
if (!test('-d', binPath)) {
    fail('node modules bin not found.  ensure npm install has been run.');
}
addPath(binPath);

// resolve list of tasks
var taskList;
if (options.task) {
    // find using --task parameter
    taskList = matchFind(options.task, path.join(__dirname, 'Tasks'), { noRecurse: true })
        .map(function (item) {
github spmjs / spm / lib / utils / check-update.js View on Github external
}, function (error, response, body) {
    if (error) {
      console.log(error);
    } else if (response.statusCode == 200) {
      var latest = JSON.parse(body)['dist-tags'].latest;
      if (semver.lt(latest, version)) {
        console.log();
        console.log(('  Your spm@' + version + ' is outdated, latest version is ' + latest + '.').to.yellow.color);
        console.log('  Try "npm install spm -g".'.to.green.color);
      }
    }
    fs.writeFileSync(UPDATE_FILE, NOW);
    callback();
  });
};
github kristianoye / kmud / src / efuns / Inputs.js View on Github external
let endRange = take(/^\d+/);
                                            if (endRange)
                                                found = args.slice(parseInt(nc), parseInt(endRange) + 1).join(' ');
                                            else
                                                found = args.slice(parseInt(nc)).join(' ');
                                        }
                                        else {
                                            let foo = parseInt(nc);
                                            if (foo < args.length)
                                                found = args[foo];
                                            else
                                                throw new Error(`:${nc}: bad word specifier`);
                                        }
                                    }
                                    else if (nc === 's' || nc === 'g') {
                                        if (semver.lt(process.version, '9.0.0')) {
                                            throw new Error('Search and replace is only available in Node v9+');
                                        }
                                        else if (take('&')) {
                                            if (!history.lastReplace)
                                                throw new Error(':g&: no previous substitution');
                                        }
                                        else {
                                            if (!take('/'))
                                                throw new Error(`Expected symbol / at position ${i}`);

                                            let searchFor = take(/^(?
github aws / aws-vsts-tools / make.js View on Github external
ensureTool('npm', '--version', function (output) {
        if (semver.lt(output, '3.0.0')) {
            fail('expected 3.0.0 or higher');
        }
    });
github jhipster / generator-jhipster / generators / upgrade / index.js View on Github external
getGitVersion(gitVersion => {
                        let args;
                        if (semver.lt(gitVersion, GIT_VERSION_NOT_ALLOW_MERGE_UNRELATED_HISTORIES)) {
                            args = ['merge', '--strategy=ours', '-q', '--no-edit', UPGRADE_BRANCH];
                        } else {
                            args = ['merge', '--strategy=ours', '-q', '--no-edit', '--allow-unrelated-histories', UPGRADE_BRANCH];
                        }
                        this.gitExec(args, { silent: this.silent }, (code, msg, err) => {
                            if (code !== 0) {
                                this.error(
                                    `Unable to record current code has been generated with version ${
                                        this.currentJhipsterVersion
                                    }:\n${msg} ${err}`
                                );
                            }
                            this.success(`Current code has been generated with version ${this.currentJhipsterVersion}`);
                            done();
                        });
                    });
github palantir / tslint / src / rules / quotemarkRule.ts View on Github external
function hasOldTscBacktickBehavior() {
    return lt(getNormalizedTypescriptVersion(), "2.7.1");
}
github valor-software / ngm-cli / src / lib / version.ts View on Github external
exports.isVersionLower = (oldVersion, newVersion) => {
  if (!isValidVersion(newVersion)) {
    throw new Error('Version should be a valid semver version.');
  }

  return semver.lt(newVersion, oldVersion);
};
github aws / aws-toolkit-vscode / src / shared / sam / cli / samCliVersion.ts View on Github external
public static validate(version?: string): SamCliVersionValidation {
        if (!version) {
            return SamCliVersionValidation.VersionNotParseable
        }

        if (!semver.valid(version)) {
            return SamCliVersionValidation.VersionNotParseable
        }

        if (semver.lt(version, this.MINIMUM_SAM_CLI_VERSION_INCLUSIVE)) {
            return SamCliVersionValidation.VersionTooLow
        }

        if (semver.gte(version, this.MAXIMUM_SAM_CLI_VERSION_EXCLUSIVE)) {
            return SamCliVersionValidation.VersionTooHigh
        }

        return SamCliVersionValidation.Valid
    }
github jenslind / electron-gh-releases / GhReleases.js View on Github external
value: function _newVersion(latest) {
      return semver.lt(this._getCurrentVersion(), latest);
    }