當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。