How to use the semver.clean 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 apache / cordova-lib / src / cordova / plugin / add.js View on Github external
var name = pluginInfo.name;

    // Filters out pre-release versions
    var latest = semver.maxSatisfying(allVersions, '>=0.0.0');

    var versions = [];
    var upperBound = null;
    var upperBoundRange = null;
    var upperBoundExists = false;

    // TODO: lots of 'versions' being thrown around in this function: cordova version,
    // platform version, plugin version. The below for loop: what version is it
    // iterating over? plugin version? please clarify the variable name.
    for (var version in engine) {
        // if a single version && less than latest
        if (semver.valid(semver.clean(version)) && semver.lte(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 (module.exports.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)');
github expo / expo-github-action / node_modules / @actions / tool-cache / lib / tool-cache.js View on Github external
function _completeToolPath(tool, version, arch) {
    const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || '');
    const markerPath = `${folderPath}.complete`;
    fs.writeFileSync(markerPath, '');
    core.debug('finished caching tool');
}
function _isExplicitVersion(versionSpec) {
github dojo / dojo.io / support / commands / typedoc.ts View on Github external
}).sort(function (a: Release, b: Release) {
		const left = semver.clean(a.name);
		const right = semver.clean(b.name);
		return semver.compare(left, right, true);
	});
github microsoft / vscode-azure-blockchain-ethereum / src / helpers / required.ts View on Github external
async function getVersion(program: string, command: string, matcher: RegExp): Promise {
    try {
      const result = await tryExecuteCommand(undefined, program, command);
      if (result.code === 0) {
        const output = result.cmdOutput || result.cmdOutputIncludingStderr;
        const installedVersion = output.match(matcher);
        const version = semver.clean(installedVersion ? installedVersion[1] : '');

        return version || '';
      }
    } catch (error) {
      Telemetry.sendException(error);
    }

    return '';
  }
}
github phonegap / phonegap-template-vue-f7-split-panel / template / build / check-versions.js View on Github external
var chalk = require('chalk');
var semver = require('semver');
var packageConfig = require('../package.json');
var shell = require('shelljs');
function exec (cmd) {
  return require('child_process').execSync(cmd).toString().trim();
}

var versionRequirements = [
  {
    name: 'node',
    currentVersion: semver.clean(process.version),
    versionRequirement: packageConfig.engines.node
  }
];

if (shell.which('npm')) {
  versionRequirements.push({
    name: 'npm',
    currentVersion: exec('npm --version'),
    versionRequirement: packageConfig.engines.npm
  });
}

module.exports = function () {
  var warnings = [];
  for (var i = 0; i < versionRequirements.length; i++) {
    var mod = versionRequirements[i];
github mubaidr / node-vue-template / frontend / build / check-versions.js View on Github external
const semver = require('semver')
const shell = require('shelljs')
const childProcess = require('child_process')
const packageConfig = require('../package.json')

function exec(cmd) {
  return childProcess
    .execSync(cmd)
    .toString()
    .trim()
}

const versionRequirements = [
  {
    name: 'node',
    currentVersion: semver.clean(process.version),
    versionRequirement: packageConfig.engines.node,
  },
]

if (shell.which('npm')) {
  versionRequirements.push({
    name: 'npm',
    currentVersion: exec('npm --version'),
    versionRequirement: packageConfig.engines.npm,
  })
}

module.exports = () => {
  const warnings = []

  for (let i = 0; i < versionRequirements.length; i += 1) {
github apache / cordova-lib / cordova-lib / src / cordova / plugin.js View on Github external
function findVersion(versions, version) {
    var cleanedVersion = semver.clean(version);
    for(var i = 0; i < versions.length; i++) {
        if(semver.clean(versions[i]) === cleanedVersion) {
            return versions[i];
        }
    }
    return null;
}
github molgenis / molgenis / molgenis-navigator / src / main / frontend / build / check-versions.js View on Github external
'use strict'
const chalk = require('chalk')
const semver = require('semver')
const packageConfig = require('../package.json')
const shell = require('shelljs')

function exec (cmd) {
  return require('child_process').execSync(cmd).toString().trim()
}

const versionRequirements = [
  {
    name: 'node',
    currentVersion: semver.clean(process.version),
    versionRequirement: packageConfig.engines.node
  }
]

if (shell.which('npm')) {
  versionRequirements.push({
    name: 'npm',
    currentVersion: exec('npm --version'),
    versionRequirement: packageConfig.engines.npm
  })
}

module.exports = function () {
  const warnings = []

  for (let i = 0; i < versionRequirements.length; i++) {
github wix / Detox / scripts / ci.common.js View on Github external
function getVersionSafe() {
  const version = semver.clean(readPackageJson().version);
  if (!version) {
    throw new Error('Error: failed to read version from package.json!');
  }
  return version;
}
github markd / markd / build / check-versions.js View on Github external
const chalk = require('chalk')
const semver = require('semver')
const packageConfig = require('../package.json')
const shell = require('shelljs')
function exec(cmd) {
  return require('child_process')
    .execSync(cmd)
    .toString()
    .trim()
}

const versionRequirements = [
  {
    name: 'node',
    currentVersion: semver.clean(process.version),
    versionRequirement: packageConfig.engines.node
  }
]

if (shell.which('npm')) {
  versionRequirements.push({
    name: 'npm',
    currentVersion: exec('npm --version'),
    versionRequirement: packageConfig.engines.npm
  })
}

module.exports = function() {
  let i
  const warnings = []
  for (i = 0; i < versionRequirements.length; i++) {