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


TypeScript SemVer.compare方法代码示例

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


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

示例1: get

    public get(entity: Entity, client: string, version: SemVer): Marshaller<Entity> {
        let className: string = entity.constructor.name;

		if (className.startsWith('Cart_')) {
			if (version.compare(new SemVer('1.0.0')) === 0) {
				return new CartMarshaller_01_00_00();
			}
			return new CartMarshaller_01_00_01();
		}

		if (className == 'Void') {
			return new VoidMarshaller();
		}

		if (className.startsWith('HomeWidgets_')) {
			if (client.startsWith('web')) {
				if (version.compare(new SemVer('1.10.0')) >= 0) {
					return new HomeWidgetsMarshaller_01_10_00();
				}
			}
			return new HomeWidgetsMarshaller_01_00_00();
		}

		return null;
    }
开发者ID:francovitali,项目名称:cart-backend-poc,代码行数:25,代码来源:marshallerLocatorService.ts

示例2: SemVer

    '@angular/cli',
    {
      checkGlobal: false,
      basedir: process.cwd(),
      preserveSymlinks: true,
    },
  );

  // This was run from a global, check local version.
  const globalVersion = new SemVer(packageJson['version']);
  let localVersion;
  let shouldWarn = false;

  try {
    localVersion = _fromPackageJson();
    shouldWarn = localVersion != null && globalVersion.compare(localVersion) > 0;
  } catch (e) {
    // eslint-disable-next-line no-console
    console.error(e);
    shouldWarn = true;
  }

  if (shouldWarn && isWarningEnabled('versionMismatch')) {
    const warning = terminal.yellow(tags.stripIndents`
    Your global Angular CLI version (${globalVersion}) is greater than your local
    version (${localVersion}). The local Angular CLI version is used.

    To disable this warning use "ng config -g cli.warnings.versionMismatch false".
    `);
    // Don't show warning colorised on `ng completion`
    if (process.argv[2] !== 'completion') {
开发者ID:baconwaffles,项目名称:angular-cli,代码行数:31,代码来源:init.ts

示例3:

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");
ver = ver.inc("patch");
ver = ver.inc("prepatch");
ver = ver.inc("prerelease");
ver = ver.inc("prerelease", "alpha");

const comp = new semver.Comparator(str, bool);
str = comp.toString();

ver = comp.semver;
开发者ID:PriceSpider-NeuIntel,项目名称:DefinitelyTyped,代码行数:30,代码来源:semver-tests.ts

示例4:

var 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;

num = ver.compare(ver);
num = ver.compareMain(ver);
num = ver.comparePre(ver);
ver = ver.inc(str);


var comp = new semver.Comparator(str, bool);
str = comp.toString();

ver = comp.semver;
str = comp.operator;
bool = comp.value;
comp.parse(str);
bool = comp.test(ver);

开发者ID:Kroisse,项目名称:DefinitelyTyped,代码行数:28,代码来源:semver-tests.ts

示例5: function

  function (error: Error, projectLocalCli: string) {
    let cli;
    if (error) {
      // If there is an error, resolve could not find the ng-cli
      // library from a package.json. Instead, include it from a relative
      // path to this script file (which is likely a globally installed
      // npm package). Most common cause for hitting this is `ng new`
      cli = require('./cli');
    } else {
      // This was run from a global, check local version.
      const globalVersion = new SemVer(packageJson['version']);
      let localVersion;
      let shouldWarn = false;

      try {
        localVersion = _fromPackageJson();
        shouldWarn = localVersion && globalVersion.compare(localVersion) > 0;
      } catch (e) {
        // eslint-disable-next-line no-console
        console.error(e);
        shouldWarn = true;
      }

      if (shouldWarn && isWarningEnabled('versionMismatch')) {
        let warning = yellow(stripIndents`
        Your global Angular CLI version (${globalVersion}) is greater than your local
        version (${localVersion}). The local Angular CLI version is used.

        To disable this warning use "ng set --global warnings.versionMismatch=false".
        `);
        // Don't show warning colorised on `ng completion`
        if (process.argv[2] !== 'completion') {
           // eslint-disable-next-line no-console
          console.log(warning);
        } else {
           // eslint-disable-next-line no-console
          console.error(warning);
          process.exit(1);
        }
      }

      // No error implies a projectLocalCli, which will load whatever
      // version of ng-cli you have installed in a local package.json
      cli = require(projectLocalCli);
    }

    if ('default' in cli) {
      cli = cli['default'];
    }

    let standardInput;
    try {
      standardInput = process.stdin;
    } catch (e) {
      delete process.stdin;
      process.stdin = new events.EventEmitter();
      standardInput = process.stdin;
    }

    cli({
      cliArgs: process.argv.slice(2),
      inputStream: standardInput,
      outputStream: process.stdout
    }).then(function (exitCode: number) {
      process.exit(exitCode);
    }).catch(function(err: Error) {
      console.log('Unknown error: ' + err.toString());
      process.exit(127);
    });
  }
开发者ID:nickroberts,项目名称:angular-cli,代码行数:70,代码来源:init.ts


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