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