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


TypeScript semver.gt函数代码示例

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


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

示例1: if

 return this.getVersionList().then(list => {
   let chromedriverVersion: string = null;
   let latest = '';
   let latestVersion = '';
   for (let item of list) {
     // Get a semantic version
     let version = item.split('/')[0];
     if (semver.valid(version) == null) {
       version += '.0';
       if (semver.valid(version)) {
         // First time: use the version found.
         if (chromedriverVersion == null) {
           chromedriverVersion = version;
           latest = item;
           latestVersion = item.split('/')[0];
         } else if (semver.gt(version, chromedriverVersion)) {
           // After the first time, make sure the semantic version is greater.
           chromedriverVersion = version;
           latest = item;
           latestVersion = item.split('/')[0];
         } else if (version === chromedriverVersion) {
           // If the semantic version is the same, check os arch.
           // For 64-bit systems, prefer the 64-bit version.
           if (this.osarch === 'x64') {
             if (item.includes(this.getOsTypeName() + '64')) {
               latest = item;
             }
           }
         }
       }
     }
   }
   return {url: Config.cdnUrls().chrome + latest, version: latestVersion};
 });
开发者ID:elgohr,项目名称:webdriver-manager,代码行数:34,代码来源:chrome_xml.ts

示例2: return

		return (() => {
			let platformData = this.$platformsData.getPlatformData(platform);

			this.$projectDataService.initialize(this.$projectData.projectDir);
			let data = this.$projectDataService.getValue(platformData.frameworkPackageName).wait();
			let currentVersion = data && data.version ? data.version : "0.2.0";
			let newVersion = version || this.$npmInstallationManager.getLatestVersion(platformData.frameworkPackageName).wait();

			let cachedPackageData = this.$npmInstallationManager.addToCache(platformData.frameworkPackageName, newVersion).wait();
			newVersion = (cachedPackageData && cachedPackageData.version) || newVersion;

			let canUpdate = platformData.platformProjectService.canUpdatePlatform(currentVersion, newVersion).wait();
			if (canUpdate) {
				if (!semver.valid(newVersion)) {
					this.$errors.fail("The version %s is not valid. The version should consists from 3 parts separated by dot.", newVersion);
				}

				if (semver.gt(currentVersion, newVersion)) { // Downgrade
					let isUpdateConfirmed = this.$prompter.confirm(`You are going to downgrade to runtime v.${newVersion}. Are you sure?`, () => false).wait();
					if (isUpdateConfirmed) {
						this.updatePlatformCore(platformData, currentVersion, newVersion, canUpdate).wait();
					}
				} else if (semver.eq(currentVersion, newVersion)) {
					this.$errors.fail("Current and new version are the same.");
				} else {
					this.updatePlatformCore(platformData, currentVersion, newVersion, canUpdate).wait();
				}
			} else {
				this.updatePlatformCore(platformData, currentVersion, newVersion, canUpdate).wait();
			}

		}).future<void>()();
开发者ID:NickBranstein,项目名称:nativescript-cli,代码行数:32,代码来源:platform-service.ts

示例3: versionUpdateAvailable

function versionUpdateAvailable(
  packageInfo: Package,
  uiMetadata: UIMetadata
): FormattedPackageVersion | null {
  const currentVersion = parseCurrentVersion(uiMetadata);
  if (currentVersion === null) {
    return null;
  }
  // Compare to package versions to find the greatest available version
  const availableVersions = packageInfo.versions
    .map(val => ({ display: semver.coerce(val.version), ...val }))
    .filter((val: FormattedPackageVersion) => val.display !== null)
    .filter(
      (val: FormattedPackageVersion) =>
        // @ts-ignore
        val.display.major === currentVersion.major
    )
    .sort((a: FormattedPackageVersion, b: FormattedPackageVersion) =>
      // @ts-ignore
      semver.rcompare(a.display, b.display)
    );
  if (availableVersions.length === 0) {
    return null;
  }
  // if greatest version !== installed version, return it, otherwise return null
  // @ts-ignore
  if (semver.gt(availableVersions[0].display, currentVersion)) {
    return availableVersions[0];
  }
  return null;
}
开发者ID:dcos,项目名称:dcos-ui,代码行数:31,代码来源:index.ts

示例4: if

    return this.getVersionList().then(list => {
      let standaloneVersion: string = null;
      let latest = '';
      let latestVersion = '';
      for (let item of list) {
        // Get a semantic version.
        let version = item.split('selenium-server-standalone-')[1].replace('.jar', '');

        // Do not do beta versions for latest.
        if (!version.includes('beta')) {
          if (standaloneVersion == null) {
            // First time: use the version found.
            standaloneVersion = version;
            latest = item;
            latestVersion = version;
          } else if (semver.gt(version, standaloneVersion)) {
            // Get the latest.
            standaloneVersion = version;
            latest = item;
            latestVersion = version;
          }
        }
      }
      return {url: Config.cdnUrls().selenium + latest, version: latestVersion};
    });
开发者ID:elgohr,项目名称:webdriver-manager,代码行数:25,代码来源:standalone_xml.ts

示例5:

		.then(() => {
			if (latestVersion && semver.gt(latestVersion, pkg.version)) {
				console.log(`\nThe latest version of ${ pkg.name } is ${ latestVersion } and you have ${ pkg.version }.\nUpdate it now: npm install -g ${ pkg.name }`);
			} else {
				token.cancel();
			}
		});
开发者ID:rlugojr,项目名称:vscode-vsce,代码行数:7,代码来源:main.ts

示例6: setPackageVersions

async function setPackageVersions(packageData: Array<any>) {
  const versions = await getLatestVersions(packageData)
  let publishScript = `#!/usr/bin/env bash
set -e
  
ln -f README.md packages/electron-builder/README.md
`

  for (let i = 0; i < packageData.length; i++) {
    const packageMetadata = packageData[i]
    const packageName = packageMetadata.name
    const versionInfo = versions[i]
    const latestVersion = versionInfo.next || versionInfo.latest
    if (latestVersion == null || packageMetadata.version === latestVersion || semver.lt(latestVersion, packageMetadata.version)) {
      continue
    }

    packageMetadata.version = latestVersion
    console.log(`Set ${packageName} version to ${latestVersion}`)
    await writeJson(path.join(packageDir, packageName, "package.json"), packageMetadata, {spaces: 2})
  }

  for (let i = 0; i < packageData.length; i++) {
    const packageMetadata = packageData[i]
    const versionInfo = versions[i]
    const latestVersion = versionInfo.next || versionInfo.latest
    if (latestVersion != null && semver.gt(packageMetadata.version, latestVersion)) {
      publishScript += `npm publish packages/${packageMetadata.name}\n`
    }
  }

  await writeFile(path.join(rootDir, "__publish.sh"), publishScript)
}
开发者ID:electron-userland,项目名称:electron-builder,代码行数:33,代码来源:setVersions.ts

示例7: if

 return changelogs.sort((a, b) => {
     if (semver.gt(a.version, b.version)) {
         return -1;
     } else if (semver.lt(a.version, b.version)) {
         return 1;
     } else {
         return 0;
     }
 });
开发者ID:suiruiw,项目名称:geeks-diary,代码行数:9,代码来源:changelog.ts

示例8: function

export default function(options: SchematicsUpdateSchema): Rule {
  const version = options.version || 'latest';
  if (semver.valid(version)) {
    if (!semver.gt(version, '4.0.0')) {
      throw new SchematicsException('You cannot use a version of Angular older than 4.');
    }
  }

  return updatePackageJson(angularPackagesName, options.version, options.loose);
}
开发者ID:fmalcher,项目名称:angular-cli,代码行数:10,代码来源:index.ts

示例9: compareVersion

 public static compareVersion(versionA: string, versionB: string) {
     try {
         versionA = VersionUtils.convertToSemver(versionA);
         versionB = VersionUtils.convertToSemver(versionB);
         return semver.gt(versionA, versionB) ? 1 : 0;
     }
     catch {
         return 0;
     }
 }
开发者ID:,项目名称:,代码行数:10,代码来源:

示例10:

 downloaded.versions = downloaded.versions.sort((a: string, b: string): number => {
   if (!semver.valid(a)) {
     a += '.0';
     b += '.0';
   }
   if (semver.gt(a, b)) {
     return 1;
   } else {
     return 0;
   }
 });
开发者ID:elgohr,项目名称:webdriver-manager,代码行数:11,代码来源:status.ts


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