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


TypeScript semver.parse函数代码示例

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


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

示例1: getNextVersionNumber

export function getNextVersionNumber(
  version: string,
  channel: Channel
): string {
  const semanticVersion = parse(version)

  if (semanticVersion == null) {
    throw new Error(`Unable to parse input '${version}' into version`)
  }

  switch (channel) {
    case 'production':
      if (isBetaTag(semanticVersion)) {
        throw new Error(
          `Unable to draft production release using beta version '${version}'`
        )
      }

      if (isTestTag(semanticVersion)) {
        throw new Error(
          `Unable to draft production release using test version '${version}'`
        )
      }

      const nextVersion = inc(version, 'patch')
      if (nextVersion == null) {
        throw new Error(
          `Unable to increment next production version from release version '${version}'`
        )
      }

      return nextVersion

    case 'beta':
      if (isTestTag(semanticVersion)) {
        throw new Error(
          `Unable to draft beta release using test version '${version}'`
        )
      }

      const betaNumber = tryGetBetaNumber(semanticVersion)

      if (betaNumber) {
        return semanticVersion.version.replace(
          `-beta${betaNumber}`,
          `-beta${betaNumber + 1}`
        )
      } else {
        const nextVersion = inc(semanticVersion, 'patch')
        const firstBeta = `${nextVersion}-beta1`
        return firstBeta
      }

    default:
      throw new Error(
        `Resolving the next version is not implemented for channel ${channel}`
      )
  }
}
开发者ID:ghmoore,项目名称:desktop,代码行数:59,代码来源:version.ts

示例2: require

 nvim.channelId.then(async channelId => {
   if (isTest) nvim.command(`let g:coc_node_channel_id = ${channelId}`, true)
   let json = require('../package.json')
   let { major, minor, patch } = semver.parse(json.version)
   nvim.setClientInfo('coc', { major, minor, patch }, 'remote', {}, {})
   let entered = await nvim.getVvar('vim_did_enter')
   if (entered && !initialized) {
     initialized = true
     await plugin.init()
   }
 }).catch(e => {
开发者ID:demelev,项目名称:coc.nvim,代码行数:11,代码来源:attach.ts

示例3: ghGot

    .then(([body, markdown]) => {
      const json = body.body;

      const maybeRelease = json.find((x: JsonObject) => x.tag_name == args.to);
      const id = maybeRelease ? `/${maybeRelease.id}` : '';

      const semversion = (args.to && semver.parse(args.to)) || { prerelease: '' };

      return ghGot('repos/angular/angular-cli/releases' + id, {
        body: {
          body: markdown,
          draft: !maybeRelease,
          name: args.to,
          prerelease: semversion.prerelease.length > 0,
          tag_name: args.to,
          ...(toSha ? { target_commitish: toSha } : {}),
        },
        token: githubToken,
      });
    });
开发者ID:fmalcher,项目名称:angular-cli,代码行数:20,代码来源:changelog.ts

示例4: main

async function main() {
  const json = require('../package.json');

  // determine commit from either circle ci or last git commit
  let commit = process.env.CIRCLE_SHA1;
  if (!commit) {
    const lastCommit = await execute('git rev-parse HEAD');
    commit = lastCommit.toString().trim();
  }

  // shorten commit
  commit = commit!.slice(0, 7);

  // construct new version from base version 2.0.0 to become 2.0.0+dev.shortsha
  const version: SemVer = parse(json.version)!;
  const newVersion = `${version.major}.${version.minor}.${version.patch}-dev.master-${commit}`;

  console.log('publishing new version', newVersion);

  // run through all our packages and push them to npm
  await publishAllPackagesToNpm(newVersion, 'dev');
}
开发者ID:LucasFrecia,项目名称:store,代码行数:22,代码来源:publish-dev-builds.ts

示例5:

let op: semver.Operator = '';
let arr: any[];
let exp: RegExp;
let strArr: string[] | null;
let numArr: string[];
let comparatorResult: -1 | 0 | 1;
let versionsArr: Array<string | semver.SemVer>;

let v1: string = '';
let v2: string = '';
let version: string = '';
let versions: string[] = [];
let loose: boolean = true;
let sem: semver.SemVer | null;

sem = semver.parse(str);
strn = semver.valid(str);
strn = semver.clean(str);

strn = semver.valid(str, loose);
strn = semver.clean(str, loose);
strn = semver.inc(str, "major", loose);
strn = semver.inc(str, "premajor", loose);
strn = semver.inc(str, "minor", loose);
strn = semver.inc(str, "preminor", loose);
strn = semver.inc(str, "patch", loose);
strn = semver.inc(str, "prepatch", loose);
strn = semver.inc(str, "prerelease", loose);
strn = semver.inc(str, "prerelease", loose, "alpha");
num = semver.major(str, loose);
num = semver.minor(str, loose);
开发者ID:PriceSpider-NeuIntel,项目名称:DefinitelyTyped,代码行数:31,代码来源:semver-tests.ts


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