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