当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript semver.satisfies函数代码示例

本文整理汇总了TypeScript中semver.satisfies函数的典型用法代码示例。如果您正苦于以下问题:TypeScript satisfies函数的具体用法?TypeScript satisfies怎么用?TypeScript satisfies使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了satisfies函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: match

export function match(range: string, versions: string[], tags: Dictionary<string> = {}): string {
    if (Semver.validRange(range)) {
        versions = versions.sort(Semver.rcompare);

        let latest = tags['latest'] || versions[0];

        for (let version of versions) {
            if (Semver.gte(latest, version) && Semver.satisfies(version, range)) {
                return version;
            }
        }

        for (let version of versions) {
            if (Semver.satisfies(version, range)) {
                return version;
            }
        }

        if (range === '*') {
            return latest;
        }

        return undefined;
    } else {
        // Otherwise, treat it as a tag (according to NPM source code).
        return hasOwnProperty.call(tags, range) ? tags[range] : undefined;
    }
}
开发者ID:vilic,项目名称:semver-match,代码行数:28,代码来源:index.ts

示例2: cleanupPolymer

async function cleanupPolymer(element: ElementRepo): Promise<void> {
  const bowerPath = path.join(element.dir, 'bower.json');
  if (!existsSync(bowerPath)) {
    return;  // No Bower file, skip generating polymer.json
  }
  // Read bower.json for Polymer version to better set Polymer lint rules
  const bowerConfig: any = JSON.parse(fs.readFileSync(bowerPath, 'utf8'));

  if (!bowerConfig || !bowerConfig.dependencies ||
      bowerConfig.dependencies.length === 0 ||
      !bowerConfig.dependencies.polymer) {
    return;  // Not using Polymer, skip generating polymer.json
  }

  const polymerDefault: ProjectOptions = {lint: {rules: []}};

  let polymerConfig: ProjectOptions = polymerDefault;
  const polymerPath = path.join(element.dir, 'polymer.json');
  const configExists = existsSync(polymerPath);
  if (configExists) {
    polymerConfig =
        JSON.parse(fs.readFileSync(polymerPath, 'utf8')) || polymerDefault;
  }

  // Skip if lint rule(s) exist
  if (polymerConfig.lint && polymerConfig.lint.rules &&
      polymerConfig.lint.rules.length > 0) {
    return;
  } else {
    // Default lint property if it doesn't exist
    polymerConfig.lint = polymerDefault.lint as LintOptions;
  }

  // Update the lint property based on the Polymer version
  const polymerVersion = bowerConfig.dependencies.polymer.split('#')[1];
  if (semver.satisfies('2.0', polymerVersion)) {
    if (semver.satisfies('1.9', polymerVersion)) {
      polymerConfig.lint.rules.push('polymer-2-hybrid');
    } else {
      polymerConfig.lint.rules.push('polymer-2');
    }
  } else {
    polymerConfig.lint.rules.push('polymer-1');
  }

  // Write the Polymer config object out to the given path
  writeToConfig(polymerPath, polymerConfig);
  let commitMsg: string = 'Add basic polymer config';
  if (configExists) {
    commitMsg = 'Add polymer lint property';
  }
  await makeCommit(element, ['polymer.json'], commitMsg);
}
开发者ID:TimvdLippe,项目名称:tedium,代码行数:53,代码来源:polymer-json.ts

示例3: exec

 exec('"' + grunt.config('build.javac') + '" -version', function (err, stdout, stderr) {
   if (err) {
     throw err;
   }
   var java_version = /(\d+\.\d+\.\d+)/.exec(stderr.toString())[1];
   return cb(semver.satisfies(java_version, '<1.7.0'), java_version);
 });
开发者ID:chubbymaggie,项目名称:doppio,代码行数:7,代码来源:find_native_java.ts

示例4: getNodeWarning

export function getNodeWarning(): string {
	var verificationOpts = getNodeVersionOpts();
	var cliName = verificationOpts.cliName;
	var supportedVersionsRange = verificationOpts.supportedVersionsRange;
	var deprecatedVersions = verificationOpts.deprecatedVersions;
	var nodeVer = verificationOpts.nodeVer;

	var warningMessage = "";
	if (deprecatedVersions) {
		deprecatedVersions.forEach(function (version) {
			if (semver.satisfies(nodeVer, version)) {
				warningMessage = "Support for Node.js " + version + " is deprecated and will be removed in one of the next releases of " + cliName +
					". Please, upgrade to the latest Node.js LTS version. ";
				return warningMessage;
			}
		});
	}

	if (!warningMessage) {
		var checkSatisfied = semver.satisfies(nodeVer, supportedVersionsRange);
		if (!checkSatisfied) {
			warningMessage = "Support for Node.js " + nodeVer + " is not verified. " + cliName + " CLI might not install or run properly.";
		}
	}

	return warningMessage;
}
开发者ID:telerik,项目名称:mobile-cli-lib,代码行数:27,代码来源:verify-node-version.ts

示例5: exec

 exec(grunt.config('build.javac') + ' -version', function(err, stdout, stderr) {
   var java_version = /(\d+\.\d+\.\d+)/.exec(stderr.toString())[1];
   if (!semver.satisfies(java_version, '<1.7.0')) {
     grunt.fail.fatal('Detected Java '+java_version+' (via javac). Please use Java <= 1.6');
   }
   return cb();
 });
开发者ID:cyy0418,项目名称:doppio,代码行数:7,代码来源:find_native_java.ts

示例6:

			deprecatedVersions.forEach(function (version) {
				if (semver.satisfies(nodeVer, version)) {
					warningMessage = "Support for Node.js " + version + " is deprecated and will be removed in one of the next releases of " + cliName +
						". Please, upgrade to the latest Node.js LTS version. ";
					return warningMessage;
				}
			});
开发者ID:NativeScript,项目名称:nativescript-cli,代码行数:7,代码来源:verify-node-version.ts

示例7: checkNodeVersion

function checkNodeVersion() {
  const packageJsonPath = path.resolve(
    process.cwd(),
    'node_modules',
    'tux-scripts',
    'package.json'
  )
  const packageJson = require(packageJsonPath)
  if (!packageJson.engines || !packageJson.engines.node) {
    return
  }

  if (!semver.satisfies(process.version, packageJson.engines.node)) {
    console.error(
      chalk.red(
        'You are running Node %s.\n' +
          'Tux requires Node %s or higher. \n' +
          'Please update your version of Node.'
      ),
      process.version,
      packageJson.engines.node
    )
    process.exit(1)
  }
}
开发者ID:aranja,项目名称:tux,代码行数:25,代码来源:new.ts

示例8: _validateReversePeerDependencies

function _validateReversePeerDependencies(
  name: string,
  version: string,
  infoMap: Map<string, PackageInfo>,
  logger: logging.LoggerApi,
) {
  for (const [installed, installedInfo] of infoMap.entries()) {
    const installedLogger = logger.createChild(installed);
    installedLogger.debug(`${installed}...`);
    const peers = (installedInfo.target || installedInfo.installed).packageJson.peerDependencies;

    for (let [peer, range] of Object.entries(peers || {})) {
      if (peer != name) {
        // Only check peers to the packages we're updating. We don't care about peers
        // that are unmet but we have no effect on.
        continue;
      }

      // Override the peer version range if it's whitelisted.
      range = _updatePeerVersion(infoMap, peer, range);

      if (!semver.satisfies(version, range)) {
        logger.error([
          `Package ${JSON.stringify(installed)} has an incompatible peer dependency to`,
          `${JSON.stringify(name)} (requires ${JSON.stringify(range)},`,
          `would install ${JSON.stringify(version)}).`,
        ].join(' '));

        return true;
      }
    }
  }

  return false;
}
开发者ID:iwe7,项目名称:devkit,代码行数:35,代码来源:index.ts

示例9: return

 .filter((a: Message) => {
     return (
         !read[a.id] && a.from <= now &&
         a.until >= now &&
         (!a.platform || a.platform.includes(platform)) &&
         (!a.subStatus || a.subStatus.includes(this.settings.syncSubStatus)) &&
         (!a.version || satisfies(this.settings.version, a.version))
     );
 });
开发者ID:MaKleSoft,项目名称:padlock,代码行数:9,代码来源:messages.ts

示例10: validPackageManagerVersion

export function validPackageManagerVersion(packageManager: string, version: string, whitelistedVersions: string, ora: OraImpl) {
  try {
    return semver.satisfies(version, whitelistedVersions);
  } catch (e) {
    ora.warn!(`Could not check ${packageManager} version "${version}", assuming incompatible`);
    d(`Exception while checking version: ${e}`);
    return false;
  }
}
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:9,代码来源:check-system.ts


注:本文中的semver.satisfies函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。