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


TypeScript SemVer.toString方法代码示例

本文整理汇总了TypeScript中semver.SemVer.toString方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SemVer.toString方法的具体用法?TypeScript SemVer.toString怎么用?TypeScript SemVer.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在semver.SemVer的用法示例。


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

示例1: patch

export default function patch(args: string[], opts: any, logger: logging.Logger): void {
  const newVersion = args[0];
  const incFn = opts.patch ? (v: SemVer) => v.inc('patch') : (v: SemVer) => v;

  if (!newVersion) {
    logger.fatal('Need to pass in a new version.');
    return;
  }

  const { packages } = require('../../../lib/packages');
  const rootPackageJson = path.join(__dirname, '../../../package.json');

  for (const packageName of Object.keys(packages)) {
    if (packageName == 'angular-cli') {
      // Skip the main package.
      continue;
    }

    const pkgJson = require(packages[packageName].packageJson);
    const version = new SemVer(pkgJson['version']);
    const oldVersion = version.toString();

    pkgJson['version'] = incFn(version).toString();
    fs.writeFileSync(packages[packageName].packageJson, JSON.stringify(pkgJson, null, 2) + '\n');

    logger.info(`${packageName}: ${oldVersion} => ${pkgJson['version']}`);
  }

  // Do the main package.
  const angularCliPackageJson = require(rootPackageJson);
  angularCliPackageJson['version'] = newVersion;
  fs.writeFileSync(rootPackageJson, JSON.stringify(angularCliPackageJson, null, 2) + '\n');
}
开发者ID:headinclouds,项目名称:angular-cli,代码行数:33,代码来源:update-version.ts

示例2:

// Ranges
str = semver.validRange(str, loose);
bool = semver.satisfies(version, str, loose);
str = semver.maxSatisfying(versions, str, loose);
str = semver.minSatisfying(versions, str, loose);
bool = semver.gtr(version, str, loose);
bool = semver.ltr(version, str, loose);
bool = semver.outside(version, str, '<', loose);
bool = semver.intersects(str, str, loose);

let ver = new semver.SemVer(str, bool);
str = ver.raw;
bool = ver.loose;
str = ver.format();
str = ver.inspect();
str = ver.toString();

num = ver.major;
num = ver.minor;
num = ver.patch;
str = ver.version;
strArr = ver.build;
strArr = ver.prerelease;

comparatorResult = ver.compare(ver);
comparatorResult = ver.compareMain(ver);
comparatorResult = ver.comparePre(ver);
ver = ver.inc("major");
ver = ver.inc("premajor");
ver = ver.inc("minor");
ver = ver.inc("preminor");
开发者ID:PriceSpider-NeuIntel,项目名称:DefinitelyTyped,代码行数:31,代码来源:semver-tests.ts


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