• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript semver.eq函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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:Emat12,项目名称:nativescript-cli,代码行数:32,代码来源:platform-service.ts


示例2: updatePlatform

	private async updatePlatform(platform: string, version: string, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions): Promise<void> {
		const platformData = this.$platformsData.getPlatformData(platform, projectData);

		const data = this.$projectDataService.getNSValue(projectData.projectDir, platformData.frameworkPackageName);
		const currentVersion = data && data.version ? data.version : "0.2.0";

		const installedModuleDir = temp.mkdirSync("runtime-to-update");
		let newVersion = version === constants.PackageVersion.NEXT ?
			await this.$packageInstallationManager.getNextVersion(platformData.frameworkPackageName) :
			version || await this.$packageInstallationManager.getLatestCompatibleVersion(platformData.frameworkPackageName);
		await this.$pacoteService.extractPackage(`${platformData.frameworkPackageName}@${newVersion}`, installedModuleDir);
		const cachedPackageData = this.$fs.readJson(path.join(installedModuleDir, "package.json"));
		newVersion = (cachedPackageData && cachedPackageData.version) || newVersion;

		const canUpdate = platformData.platformProjectService.canUpdatePlatform(installedModuleDir, projectData);
		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)) {
				await this.updatePlatformCore(platformData, { currentVersion, newVersion, canUpdate, platformTemplate }, projectData, config);
			} else if (semver.eq(currentVersion, newVersion)) {
				this.$errors.fail("Current and new version are the same.");
			} else {
				this.$errors.fail(`Your current version: ${currentVersion} is higher than the one you're trying to install ${newVersion}.`);
			}
		} else {
			this.$errors.failWithoutHelp("Native Platform cannot be updated.");
		}
	}
开发者ID:NativeScript,项目名称:nativescript-cli,代码行数:31,代码来源:platform-service.ts


示例3: isLatestVersionInstalled

	public async isLatestVersionInstalled(): Promise<boolean> {
		const extensionData = this.getExtensionData();
		if (extensionData) {
			const latestVersion = await this.$npmInstallationManager.getLatestVersion(constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME);
			return semver.eq(latestVersion, extensionData.version);
		}

		return false;
	}
开发者ID:NathanaelA,项目名称:nativescript-cli,代码行数:9,代码来源:nativescript-cloud-extension-service.ts


示例4:

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);
num = semver.patch(str, loose);
strArr = semver.prerelease(str, loose);

// Comparison
bool = semver.gt(v1, v2, loose);
bool = semver.gte(v1, v2, loose);
bool = semver.lt(v1, v2, loose);
bool = semver.lte(v1, v2, loose);
bool = semver.eq(v1, v2, loose);
bool = semver.neq(v1, v2, loose);
bool = semver.cmp(v1, op, v2, loose);
comparatorResult = semver.compare(v1, v2, loose);
comparatorResult = semver.rcompare(v1, v2, loose);
comparatorResult = semver.compareIdentifiers(str, str);
comparatorResult = semver.rcompareIdentifiers(str, str);
versionsArr = semver.sort(['', new semver.SemVer('')]);
versionsArr = semver.rsort(['', new semver.SemVer('')]);
diff = semver.diff(v1, v2, loose);

// Ranges
str = semver.validRange(str, loose);
bool = semver.satisfies(version, str, loose);
str = semver.maxSatisfying(versions, str, loose);
str = semver.minSatisfying(versions, str, loose);
开发者ID:PriceSpider-NeuIntel,项目名称:DefinitelyTyped,代码行数:31,代码来源:semver-tests.ts


示例5:

 return Object.keys(manifest.versions).sort((a, b) => {
     return semver.gt(a, b) ? 1 : semver.eq(a, b) ? 0 : -1;
 });
开发者ID:sumbach,项目名称:packagephobia,代码行数:3,代码来源:npm-api.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript semver.gt函数代码示例发布时间:2022-05-25
下一篇:
TypeScript semver.compare函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap